"use strict";

var __extends = this && this.__extends || function() {
    var extendStatics = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(d, b) {
        d.__proto__ = b;
    } || function(d, b) {
        for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]);
    };
    return function(d, b) {
        function __() {
            this.constructor = d;
        }
        extendStatics(d, b), d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, 
        new __());
    };
}(), powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var DonutLabelUtils;
        !function(DonutLabelUtils) {
            function getLabelLeaderLineForDonutChart(donutArcDescriptor, donutProperties, parentPoint, sliceArc) {
                void 0 === sliceArc && (sliceArc = 0);
                var textPoint, midPoint, chartPoint, innerLinePointMultiplier = 2.05;
                if (sliceArc) {
                    var arc = sliceArc, outerRadius = donutProperties.radius * donutProperties.outerArcRadiusRatio, innerRadius = donutProperties.radius / 2 * donutProperties.innerArcRadiusRatio;
                    midPoint = [ Math.cos(arc) * outerRadius, Math.sin(arc) * outerRadius ], chartPoint = [ Math.cos(arc) * innerRadius, Math.sin(arc) * innerRadius ];
                } else midPoint = donutProperties.outerArc.centroid(donutArcDescriptor), chartPoint = donutProperties.arc.centroid(donutArcDescriptor);
                var textPointX = parentPoint.x, lineMargin = visuals.LabelUtils.maxLabelOffset / 2;
                return textPointX += textPointX < 0 ? -lineMargin : lineMargin, textPoint = [ textPointX, parentPoint.y ], 
                chartPoint[0] *= innerLinePointMultiplier, chartPoint[1] *= innerLinePointMultiplier, 
                [ chartPoint, midPoint, textPoint ];
            }
            function getLabelLeaderLinesSizeForDonutChart(leaderLinePoints) {
                if (leaderLinePoints && leaderLinePoints.length > 2) {
                    var diagonalLineSize = {
                        width: Math.abs(leaderLinePoints[1][0] - leaderLinePoints[0][0]),
                        height: Math.abs(leaderLinePoints[1][1] - leaderLinePoints[0][1])
                    }, horizontalLineSize = {
                        width: Math.abs(leaderLinePoints[2][0] - leaderLinePoints[1][0]),
                        height: visuals.NewDataLabelUtils.LineStrokeWidth
                    };
                    return [ diagonalLineSize, horizontalLineSize ];
                }
                return null;
            }
            function getXPositionForDonutLabel(textPointX) {
                var margin = textPointX < 0 ? -visuals.LabelUtils.maxLabelOffset : visuals.LabelUtils.maxLabelOffset;
                return textPointX += margin;
            }
            function getSpaceAvailableForDonutLabels(labelXPos, viewport) {
                return viewport.width / 2 - Math.abs(labelXPos) - visuals.LabelUtils.maxLabelOffset;
            }
            DonutLabelUtils.DiagonalLineIndex = 0, DonutLabelUtils.HorizontalLineIndex = 1, 
            DonutLabelUtils.getLabelLeaderLineForDonutChart = getLabelLeaderLineForDonutChart, 
            DonutLabelUtils.getLabelLeaderLinesSizeForDonutChart = getLabelLeaderLinesSizeForDonutChart, 
            DonutLabelUtils.getXPositionForDonutLabel = getXPositionForDonutLabel, DonutLabelUtils.getSpaceAvailableForDonutLabels = getSpaceAvailableForDonutLabels;
        }(DonutLabelUtils = visuals.DonutLabelUtils || (visuals.DonutLabelUtils = {}));
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var InteractiveOptions, createClassAndSelector = jsCommon.CssConstants.createClassAndSelector, EnumExtensions = jsCommon.EnumExtensions, labelStyleFlagEnum = visuals.labelStyle.labelStyleFlagEnum, LabelStyle = visuals.labelStyle;
        !function(InteractiveOptions) {
            InteractiveOptions.animationDurationMs = 500, InteractiveOptions.ease = "cubic-in-out";
        }(InteractiveOptions || (InteractiveOptions = {}));
        var DonutChart = function() {
            function DonutChart(options) {
                options && (this.sliceWidthRatio = options.sliceWidthRatio, this.animator = options.animator, 
                this.isScrollable = !!options.isScrollable && options.isScrollable, this.disableGeometricCulling = !!options.disableGeometricCulling && options.disableGeometricCulling, 
                this.behavior = options.behavior, this.tooltipsEnabled = options.tooltipsEnabled, 
                this.touchScreenOptimizedTooltipsEnabled = options.touchScreenOptimizedTooltipsEnabled, 
                options.smallViewPortProperties && (this.maxHeightToScaleDonutLegend = options.smallViewPortProperties.maxHeightToScaleDonutLegend), 
                this.customFontFamily = options.customFontFamily, this.customFontFamilyForDataLabel = options.customFontFamilyForDataLabel), 
                null == this.sliceWidthRatio && (this.sliceWidthRatio = DonutChart.defaultSliceWidthRatio);
            }
            return DonutChart.getDefaultDonutLabelSettings = function() {
                var labelSettings = visuals.LabelUtils.getDefaultLabelSettings(!0, visuals.LabelUtils.defaultLabelColor, visuals.LabelUtils.DefaultFontSizeInPt);
                return labelSettings.labelStyle = LabelStyle.category, labelSettings.percentagePrecision = visuals.dataLabelUtils.defaultPercentageLabelPrecision, 
                labelSettings;
            }, DonutChart.converter = function(dataView, style, viewport, disableGeometricCulling, interactivityService, tooltipsEnabled) {
                void 0 === tooltipsEnabled && (tooltipsEnabled = !0);
                var converter = new DonutChartConversion.DonutChartConverter(dataView, style, tooltipsEnabled);
                converter.convert();
                var d3PieLayout = d3.layout.pie().sort(null).value(function(d) {
                    return d.percentage;
                });
                interactivityService && (interactivityService.applySelectionStateToData(converter.dataPoints), 
                interactivityService.applySelectionStateToData(converter.legendData.dataPoints));
                var culledDataPoints = !disableGeometricCulling && viewport ? DonutChart.cullDataByViewport(converter.dataPoints, converter.maxValue, viewport) : converter.dataPoints;
                return {
                    dataPointsToDeprecate: culledDataPoints,
                    dataPoints: d3PieLayout(culledDataPoints),
                    unCulledDataPoints: converter.dataPoints,
                    dataPointsToEnumerate: converter.legendData.dataPoints,
                    legendData: converter.legendData,
                    hasHighlights: converter.hasHighlights,
                    highlightsOverflow: converter.highlightsOverflow,
                    dataLabelsSettings: converter.dataLabelsSettings,
                    legendObjectProperties: converter.legendObjectProperties,
                    maxValue: converter.maxValue,
                    visibleGeometryCulled: converter.dataPoints.length !== culledDataPoints.length,
                    hasNegativeValues: converter.hasNegativeValues,
                    allValuesAreNegative: converter.allValuesAreNegative
                };
            }, DonutChart.prototype.init = function(options) {
                this.options = options;
                var element = options.element;
                element.empty(), this.parentViewport = options.viewport, this.currentViewport = {
                    height: options.viewport.height,
                    width: options.viewport.width
                }, this.formatter = visuals.valueFormatter.format;
                var legendData = visuals.Legend.getDefaultLegendData();
                if (this.data = {
                    dataPointsToDeprecate: [],
                    dataPointsToEnumerate: [],
                    dataPoints: [],
                    unCulledDataPoints: [],
                    legendData: legendData,
                    hasHighlights: !1,
                    highlightsOverflow: !1,
                    dataLabelsSettings: DonutChart.getDefaultDonutLabelSettings(),
                    hasNegativeValues: !1,
                    allValuesAreNegative: !1
                }, this.drilled = !1, this.allowDrilldown = !1, this.style = options.style, this.colors = this.style.colorPalette.dataColors, 
                this.radius = 0, this.isInteractive = options.interactivity && options.interactivity.isInteractiveLegend, 
                this.behavior && (this.interactivityService = visuals.createInteractivityService(options.host)), 
                this.legend = visuals.createLegend(element, options.interactivity && options.interactivity.isInteractiveLegend, this.interactivityService, this.isScrollable), 
                this.hostService = options.host, this.tooltipService = visuals.createTooltipService(options.host, this.touchScreenOptimizedTooltipsEnabled), 
                this.isInteractive) {
                    var legendContainer = this.legendContainer = d3.select(element.get(0)).append("div").classed(DonutChart.InteractiveLegendClassName, !0);
                    this.interactivityState = {
                        interactiveLegend: new DonutChartInteractiveLegend(this, legendContainer, this.colors, options),
                        valueToAngleFactor: 0,
                        sliceAngles: [],
                        currentRotate: 0,
                        interactiveChosenSliceFinishedSetting: !1,
                        lastChosenInteractiveSliceIndex: 0,
                        totalDragAngleDifference: 0,
                        currentIndexDrag: 0,
                        previousIndexDrag: 0,
                        previousDragAngle: 0,
                        donutCenter: {
                            x: 0,
                            y: 0
                        }
                    };
                }
                this.svg = d3.select(element.get(0)).append("svg").style("position", "absolute").classed(DonutChart.ClassName, !0), 
                this.behavior && (this.clearCatcher = visuals.appendClearCatcher(this.svg)), this.mainGraphicsContext = this.svg.append("g"), 
                this.mainGraphicsContext.append("g").classed("slices", !0), this.labelGraphicsContext = this.svg.append("g").classed(visuals.LabelUtils.labelGraphicsContextClass.class, !0), 
                this.pie = d3.layout.pie().sort(null).value(function(d) {
                    return d.percentage;
                });
            }, DonutChart.prototype.update = function(options) {
                var viewport = options.viewport;
                this.parentViewport = viewport;
                var dataViews = this.dataViews = options.dataViews;
                if (dataViews && dataViews.length > 0 && dataViews[0].categorical ? (this.data = DonutChart.converter(dataViews[0], this.style, this.currentViewport, this.disableGeometricCulling, this.interactivityService, this.tooltipsEnabled), 
                this.options.interactivity && this.options.interactivity.isInteractiveLegend || this.renderLegend()) : this.data = {
                    dataPointsToDeprecate: [],
                    dataPointsToEnumerate: [],
                    dataPoints: [],
                    unCulledDataPoints: [],
                    legendData: visuals.Legend.getDefaultLegendData(),
                    hasHighlights: !1,
                    highlightsOverflow: !1,
                    dataLabelsSettings: DonutChart.getDefaultDonutLabelSettings(),
                    hasNegativeValues: !1,
                    allValuesAreNegative: !1
                }, this.initViewportDependantProperties(), this.initDonutProperties(), this.updateInternal(this.data, options.suppressAnimations), 
                this.hasSetData = !0, dataViews) {
                    var warnings = visuals.getInvalidValueWarnings(dataViews, !1, !1, !1, [ "Tooltips" ]);
                    this.data.allValuesAreNegative ? warnings.push(new visuals.AllNegativeValuesWarning()) : this.data.hasNegativeValues && warnings.push(new visuals.NegativeValuesNotSupportedWarning()), 
                    this.hostService.setWarnings(warnings);
                }
            }, DonutChart.prototype.onDataChanged = function(options) {
                this.update({
                    dataViews: options.dataViews,
                    suppressAnimations: options.suppressAnimations,
                    viewport: this.currentViewport
                });
            }, DonutChart.prototype.onResizing = function(viewport) {
                this.update({
                    dataViews: this.dataViews,
                    suppressAnimations: !0,
                    viewport: viewport
                });
            }, DonutChart.prototype.enumerateObjectInstances = function(options) {
                var enumeration = new visuals.ObjectEnumerationBuilder(), dataLabelsSettings = this.data && this.data.dataLabelsSettings ? this.data.dataLabelsSettings : DonutChart.getDefaultDonutLabelSettings();
                switch (options.objectName) {
                  case "legend":
                    this.enumerateLegend(enumeration);
                    break;

                  case "dataPoint":
                    this.enumerateDataPoints(enumeration);
                    break;

                  case "labels":
                    var labelSettingOptions = {
                        enumeration: enumeration,
                        dataLabelsSettings: dataLabelsSettings,
                        show: !0,
                        displayUnits: !0,
                        precision: !0,
                        percentagePrecision: !0,
                        fontSize: !0,
                        fontFamily: this.customFontFamilyForDataLabel,
                        labelStyle: !0
                    };
                    visuals.LabelUtils.enumerateDataLabels(labelSettingOptions);
                }
                return enumeration.complete();
            }, DonutChart.prototype.enumerateDataPoints = function(enumeration) {
                var data = this.data;
                data && powerbi.requireSync("PowerBIVisuals/Visuals/common/colorEnumerationHelper").enumerateSeriesDataColors({
                    enumeration: enumeration,
                    dataPoints: visuals.LegendData.toIEnumerableDataPoints(this.data.legendData)
                });
            }, DonutChart.prototype.enumerateLegend = function(enumeration) {
                var data = this.data;
                if (data) {
                    var legendData = this.data.legendData;
                    visuals.Legend.enumerate({
                        enumeration: enumeration,
                        legendData: legendData,
                        customFontFamily: this.customFontFamily
                    });
                }
            }, DonutChart.prototype.setInteractiveChosenSlice = function(sliceIndex) {
                var _this = this;
                if (0 !== this.interactivityState.sliceAngles.length) {
                    this.interactivityState.lastChosenInteractiveSliceIndex = sliceIndex, this.interactivityState.interactiveChosenSliceFinishedSetting = !1;
                    var viewport = this.currentViewport, moduledIndex = sliceIndex % this.data.dataPoints.length, angle = this.interactivityState.sliceAngles[moduledIndex];
                    this.svg.select("g").transition().duration(InteractiveOptions.animationDurationMs).ease(InteractiveOptions.ease).attr("transform", visuals.SVGUtil.translateAndRotate(viewport.width / 2, viewport.height / 2, 0, 0, angle)).each("end", function() {
                        _this.interactivityState.interactiveChosenSliceFinishedSetting = !0;
                    }), this.interactivityState.currentRotate = angle, this.interactivityState.interactiveLegend.updateLegend(moduledIndex), 
                    this.svg.selectAll(".slice").attr("opacity", function(d, index) {
                        return index === moduledIndex ? 1 : .6;
                    }), visuals.SVGUtil.flushAllD3TransitionsIfNeeded(this.options);
                }
            }, DonutChart.prototype.calculateRadius = function() {
                var viewport = this.currentViewport;
                if (!this.isInteractive && this.data && this.data.dataLabelsSettings.show) {
                    var hw = viewport.height / viewport.width, denom = 2 + 1 / (1 + Math.exp(-5 * (hw - 1)));
                    return Math.min(viewport.height, viewport.width) / denom;
                }
                return Math.min(viewport.height, viewport.width) / 2;
            }, DonutChart.prototype.getScaleForLegendArrow = function() {
                var ratio = 1;
                return this.maxHeightToScaleDonutLegend && this.currentViewport.height < this.maxHeightToScaleDonutLegend && (ratio = this.currentViewport.height / this.maxHeightToScaleDonutLegend), 
                ratio;
            }, DonutChart.prototype.initViewportDependantProperties = function(duration) {
                void 0 === duration && (duration = 0), this.currentViewport.height = this.parentViewport.height, 
                this.currentViewport.width = this.parentViewport.width;
                var viewport = this.currentViewport;
                if (this.isInteractive) viewport.height -= DonutChart.InteractiveLegendContainerHeight; else {
                    var legendMargins = this.legend.getMargins();
                    viewport.height -= legendMargins.height, viewport.width -= legendMargins.width;
                }
                this.svg.attr({
                    width: viewport.width,
                    height: viewport.height
                }), this.isInteractive ? (this.legendContainer.style({
                    width: "100%",
                    height: DonutChart.InteractiveLegendContainerHeight + "px",
                    overflow: "hidden",
                    top: 0
                }), this.svg.style("top", DonutChart.InteractiveLegendContainerHeight)) : visuals.Legend.positionChartArea(this.svg, this.legend), 
                this.previousRadius = this.radius;
                var radius = this.radius = this.calculateRadius(), halfViewportWidth = viewport.width / 2, halfViewportHeight = viewport.height / 2;
                this.arc = d3.svg.arc(), this.outerArc = d3.svg.arc().innerRadius(radius * DonutChart.OuterArcRadiusRatio).outerRadius(radius * DonutChart.OuterArcRadiusRatio), 
                this.isInteractive ? (this.mainGraphicsContext.attr("transform", visuals.SVGUtil.translate(halfViewportWidth, halfViewportHeight)), 
                this.labelGraphicsContext.attr("transform", visuals.SVGUtil.translate(halfViewportWidth, halfViewportHeight))) : (this.mainGraphicsContext.transition().duration(duration).attr("transform", visuals.SVGUtil.translate(halfViewportWidth, halfViewportHeight)), 
                this.labelGraphicsContext.transition().duration(duration).attr("transform", visuals.SVGUtil.translate(halfViewportWidth, halfViewportHeight))), 
                visuals.SVGUtil.flushAllD3TransitionsIfNeeded(this.options);
            }, DonutChart.prototype.initDonutProperties = function() {
                this.donutProperties = {
                    viewport: this.currentViewport,
                    radius: this.radius,
                    arc: this.arc.innerRadius(0).outerRadius(this.radius * DonutChart.InnerArcRadiusRatio),
                    outerArc: this.outerArc,
                    innerArcRadiusRatio: DonutChart.InnerArcRadiusRatio,
                    outerArcRadiusRatio: DonutChart.OuterArcRadiusRatio,
                    dataLabelsSettings: this.data.dataLabelsSettings
                };
            }, DonutChart.prototype.mergeDatasets = function(first, second) {
                var secondSet = d3.set();
                second.forEach(function(d) {
                    secondSet.add(d.identity ? d.identity.getKey() : d.data.identity.getKey());
                });
                var onlyFirst = first.filter(function(d) {
                    return !secondSet.has(d.identity ? d.identity.getKey() : d.data.identity.getKey());
                }).map(function(d) {
                    var derived = powerbi.Prototype.inherit(d);
                    return void 0 === derived.percentage ? derived.data.percentage = 0 : derived.percentage = 0, 
                    derived;
                });
                return d3.merge([ second, onlyFirst ]);
            }, DonutChart.prototype.updateInternal = function(data, suppressAnimations, duration) {
                void 0 === duration && (duration = 0);
                var viewport = this.currentViewport;
                if (duration = duration || visuals.AnimatorCommon.GetAnimationDuration(this.animator, suppressAnimations), 
                this.animator) {
                    var shapes_1, innerArcRadiusRatio = DonutChart.InnerArcRadiusRatio, layout = DonutChart.getLayout(this.radius, this.sliceWidthRatio, innerArcRadiusRatio, viewport), result = void 0, highlightShapes = void 0, labelSettings = data.dataLabelsSettings, labels = [];
                    if (labelSettings && labelSettings.show && (labels = this.createLabels()), !suppressAnimations) {
                        var animationOptions = {
                            viewModel: data,
                            colors: this.colors,
                            graphicsContext: this.mainGraphicsContext,
                            labelGraphicsContext: this.labelGraphicsContext,
                            interactivityService: this.interactivityService,
                            layout: layout,
                            radius: this.radius,
                            sliceWidthRatio: this.sliceWidthRatio,
                            viewport: viewport,
                            labels: labels,
                            innerArcRadiusRatio: innerArcRadiusRatio
                        };
                        result = this.animator.animate(animationOptions), shapes_1 = result.shapes, highlightShapes = result.highlightShapes;
                    }
                    (suppressAnimations || result.failed) && (shapes_1 = DonutChart.drawDefaultShapes(this.svg, data, layout, this.radius, this.interactivityService && this.interactivityService.hasSelection(), this.sliceWidthRatio), 
                    highlightShapes = DonutChart.drawDefaultHighlightShapes(this.svg, data, layout, this.colors, this.radius, this.sliceWidthRatio), 
                    visuals.LabelUtils.drawDefaultLabels(this.labelGraphicsContext, labels, !1, !0, !0), 
                    visuals.LabelUtils.drawLabelLeaderLines(this.labelGraphicsContext, labels)), this.assignInteractions(shapes_1, highlightShapes, data), 
                    this.tooltipsEnabled && this.addTooltips(shapes_1, highlightShapes);
                } else this.updateInternalToMove(data, duration);
                visuals.SVGUtil.flushAllD3TransitionsIfNeeded(this.options);
            }, DonutChart.prototype.createLabels = function() {
                var labelLayout = new powerbi.DonutLabelLayout({
                    maximumOffset: visuals.LabelUtils.maxLabelOffset,
                    startingOffset: visuals.LabelUtils.startingLabelOffset
                }, this.donutProperties), labelDataPoints = this.createLabelDataPoints();
                return labelLayout.layout(labelDataPoints);
            }, DonutChart.prototype.createLabelDataPoints = function() {
                var data = this.data, labelDataPoints = [], measureFormatterCache = visuals.LabelUtils.createColumnFormatterCacheManager(), alternativeScale = null;
                0 === data.dataLabelsSettings.displayUnits && (alternativeScale = d3.max(data.dataPoints, function(d) {
                    return Math.abs(d.data.measure);
                }));
                for (var i = 0; i < this.data.dataPoints.length; i++) {
                    var label = this.createLabelDataPoint(data.dataPoints[i], alternativeScale, measureFormatterCache);
                    labelDataPoints.push(label);
                }
                return labelDataPoints;
            }, DonutChart.prototype.createLabelDataPoint = function(d, alternativeScale, measureFormatterCache) {
                var dataLabel, dataLabelSize, categoryLabel, categoryLabelSize, percentLabel, percentLabelSize, textSize, labelPoint = this.outerArc.centroid(d), labelX = visuals.DonutLabelUtils.getXPositionForDonutLabel(labelPoint[0]), labelY = labelPoint[1], labelSettings = this.data.dataLabelsSettings, position = labelX < 0 ? 4 : 8, pointPosition = {
                    point: {
                        x: labelX,
                        y: labelY
                    },
                    validPositions: [ position ],
                    radius: 0
                }, outsideFill = labelSettings.fontProperties.color ? labelSettings.fontProperties.color : visuals.LabelUtils.defaultLabelColor, labelSettingsStyle = visuals.LabelUtils.getLabelStyleFlagType(labelSettings.labelStyle), fontProperties = labelSettings ? labelSettings.fontProperties : visuals.LabelUtils.defaultFontProperties, tooltip = "", hasHighlights = this.data.hasHighlights, highlightsOverflow = this.data.highlightsOverflow;
                if (EnumExtensions.hasFlag(labelSettingsStyle, visuals.labelStyle.flagLabelStyleData)) {
                    var dataLabelValue = void 0;
                    dataLabelValue = hasHighlights && !highlightsOverflow ? d.data.originalHighlightValue : d.data.originalMeasure;
                    var measureFormatter = measureFormatterCache.getOrCreate(d.data.labelFormatString, labelSettings, alternativeScale);
                    dataLabel = null != dataLabelValue ? measureFormatter.format(dataLabelValue) : null, 
                    dataLabelSize = visuals.LabelUtils.getTextSize(dataLabel, fontProperties);
                }
                if (EnumExtensions.hasFlag(labelSettingsStyle, visuals.labelStyle.flagLabelStyleCategory) && (categoryLabel = d.data.label, 
                categoryLabelSize = visuals.LabelUtils.getTextSize(categoryLabel, fontProperties)), 
                EnumExtensions.hasFlag(labelSettingsStyle, visuals.labelStyle.flagLabelStylePercent)) {
                    var pctFormatString = visuals.valueFormatter.getLocalizedString("Percentage"), percentageLabelValue = hasHighlights && !highlightsOverflow ? d.data.highlightPercentage : d.data.percentage, percentLabelSettings = _.clone(labelSettings), precision = percentLabelSettings.percentagePrecision;
                    if (percentLabelSettings.displayUnits = 0, _.isFinite(precision)) {
                        var measureFormatter = measureFormatterCache.getOrCreate(pctFormatString, percentLabelSettings, null, percentLabelSettings.percentagePrecision);
                        percentLabel = null != percentageLabelValue ? measureFormatter.format(percentageLabelValue) : null;
                    } else percentLabel = visuals.valueFormatter.format(percentageLabelValue, pctFormatString);
                    percentLabelSize = visuals.LabelUtils.getTextSize(percentLabel, fontProperties);
                }
                switch (labelSettingsStyle) {
                  case labelStyleFlagEnum.categoryAndDataAndPercent:
                    tooltip = categoryLabel, dataLabel && (tooltip = tooltip + " " + dataLabel), percentLabel && (tooltip = tooltip + " (" + percentLabel + ")"), 
                    textSize = visuals.LabelUtils.getTextSize(tooltip, fontProperties);
                    break;

                  case labelStyleFlagEnum.categoryAndData:
                    tooltip = categoryLabel, dataLabel && (tooltip = tooltip + " " + dataLabel), textSize = visuals.LabelUtils.getTextSize(tooltip, fontProperties);
                    break;

                  case labelStyleFlagEnum.categoryAndPercent:
                    tooltip = categoryLabel, percentLabel && (tooltip = tooltip + " " + percentLabel), 
                    textSize = visuals.LabelUtils.getTextSize(tooltip, fontProperties);
                    break;

                  case labelStyleFlagEnum.dataAndPercent:
                    tooltip = dataLabel, percentLabel && (tooltip = tooltip + " (" + percentLabel + ")"), 
                    textSize = visuals.LabelUtils.getTextSize(tooltip, fontProperties);
                    break;

                  case labelStyleFlagEnum.data:
                    textSize = _.clone(dataLabelSize), tooltip = dataLabel;
                    break;

                  case labelStyleFlagEnum.percent:
                    textSize = _.clone(percentLabelSize), tooltip = percentLabel;
                    break;

                  case labelStyleFlagEnum.category:
                    textSize = _.clone(categoryLabelSize), tooltip = categoryLabel;
                    break;

                  default:
                    textSize = _.clone(categoryLabelSize), tooltip = categoryLabel;
                }
                var leaderLinePoints = visuals.DonutLabelUtils.getLabelLeaderLineForDonutChart(d, this.donutProperties, pointPosition.point), leaderLinesSize = visuals.DonutLabelUtils.getLabelLeaderLinesSizeForDonutChart(leaderLinePoints);
                return {
                    isPreferred: !0,
                    text: "",
                    tooltip: tooltip,
                    textSize: textSize,
                    outsideFill: outsideFill,
                    fontProperties: labelSettings.fontProperties,
                    identity: d.data.identity,
                    parentShape: pointPosition,
                    insideFill: visuals.LabelUtils.defaultInsideLabelColor,
                    parentType: 0,
                    alternativeScale: alternativeScale,
                    donutArcDescriptor: d,
                    angle: (d.startAngle + d.endAngle) / 2 - Math.PI / 2,
                    dataLabel: dataLabel,
                    dataLabelSize: dataLabelSize,
                    categoryLabel: categoryLabel,
                    categoryLabelSize: categoryLabelSize,
                    percentLabel: percentLabel,
                    percentLabelSize: percentLabelSize,
                    leaderLinePoints: leaderLinePoints,
                    linesSize: leaderLinesSize
                };
            }, DonutChart.prototype.renderLegend = function() {
                if (!this.isInteractive) {
                    var legendObjectProperties = this.data.legendObjectProperties;
                    if (legendObjectProperties) {
                        var legendData = this.data.legendData;
                        null != legendData.position && this.legend.changeOrientation(legendData.position), 
                        this.legend.drawLegend(legendData, this.parentViewport);
                    } else this.legend.changeOrientation(visuals.LegendPosition.Top), this.legend.drawLegend(visuals.Legend.getDefaultLegendData(), this.parentViewport);
                }
            }, DonutChart.prototype.addInteractiveLegendArrow = function() {
                if (this.data && this.data.dataPoints && 0 !== this.data.dataPoints.length) {
                    var arrowHeightOffset = 11, arrowWidthOffset = 16.5;
                    if (!this.interactiveLegendArrow) {
                        var interactiveLegendArrow = this.svg.append("g");
                        interactiveLegendArrow.append("path").classed(DonutChart.InteractiveLegendArrowClassName, !0).attr("d", "M1.5,2.6C0.65,1.15,1.85,0,3,0l27,0c1.65,0,2.35,1.15,1.5,2.6L18,26.45c-0.8,1.45-2.15,1.45-2.95,0L1.95,2.6z"), 
                        this.interactiveLegendArrow = interactiveLegendArrow;
                    }
                    var viewport = this.currentViewport, scaleRatio = this.getScaleForLegendArrow(), distanceBetweenLegendAndArrow = (viewport.height - 2 * this.radius) / 2 + arrowHeightOffset * scaleRatio, middleOfChart = viewport.width / 2 - arrowWidthOffset * scaleRatio;
                    this.interactiveLegendArrow.attr("transform", visuals.SVGUtil.translateAndScale(middleOfChart, distanceBetweenLegendAndArrow, scaleRatio));
                }
            }, DonutChart.prototype.calculateSliceAngles = function() {
                var angles = [], data = this.data.dataPoints;
                if (0 === data.length) return this.interactivityState.valueToAngleFactor = 0, void (this.interactivityState.sliceAngles = []);
                for (var sum = 0, i = 0, ilen = data.length; i < ilen; i++) sum += data[i].data.percentage;
                this.interactivityState.valueToAngleFactor = 360 / sum;
                for (var currentAngle = 0, i = 0, ilen = data.length; i < ilen; i++) {
                    var relativeAngle = data[i].data.percentage * this.interactivityState.valueToAngleFactor;
                    currentAngle += relativeAngle, angles.push(relativeAngle / 2 - currentAngle);
                }
                this.interactivityState.sliceAngles = angles;
            }, DonutChart.prototype.assignInteractions = function(slices, highlightSlices, data) {
                if (this.isInteractive) this.assignInteractiveChartInteractions(slices); else if (this.interactivityService) {
                    var dataPoints = data.dataPoints.map(function(value) {
                        return value.data;
                    }), behaviorOptions = {
                        clearCatcher: this.clearCatcher,
                        slices: slices,
                        highlightSlices: highlightSlices,
                        allowDrilldown: this.allowDrilldown,
                        visual: this,
                        hasHighlights: data.hasHighlights
                    };
                    this.interactivityService.bind(dataPoints, this.behavior, behaviorOptions);
                }
            }, DonutChart.prototype.assignInteractiveChartInteractions = function(slice) {
                var _this = this, svg = this.svg;
                this.interactivityState.interactiveChosenSliceFinishedSetting = !0;
                var svgRect = svg.node().getBoundingClientRect();
                this.interactivityState.donutCenter = {
                    x: svgRect.left + svgRect.width / 2,
                    y: svgRect.top + svgRect.height / 2
                }, this.interactivityState.totalDragAngleDifference = 0, this.interactivityState.currentRotate = 0, 
                this.calculateSliceAngles(), slice.on("click", function(d, clickedIndex) {
                    d3.event.defaultPrevented || _this.setInteractiveChosenSlice(clickedIndex);
                });
                var drag = d3.behavior.drag().origin(Object).on("dragstart", function() {
                    return _this.interactiveDragStart();
                }).on("drag", function() {
                    return _this.interactiveDragMove();
                }).on("dragend", function() {
                    return _this.interactiveDragEnd();
                });
                svg.style("touch-action", "none").call(drag);
            }, DonutChart.prototype.getAngleFromDragEvent = function() {
                var pageX, pageY, interactivityState = this.interactivityState, sourceEvent = d3.event.sourceEvent;
                if (sourceEvent.type.toLowerCase().indexOf("touch") !== -1) {
                    if (1 !== sourceEvent.touches.length) return null;
                    var touch = sourceEvent.touches[0];
                    pageX = touch.pageX, pageY = touch.pageY;
                } else pageX = sourceEvent.pageX, pageY = sourceEvent.pageY;
                var adjustedCoordinates = {
                    x: pageX - interactivityState.donutCenter.x,
                    y: -pageY + interactivityState.donutCenter.y
                }, angleToThePlane = 180 * Math.atan2(adjustedCoordinates.y, adjustedCoordinates.x) / Math.PI;
                return angleToThePlane;
            }, DonutChart.prototype.interactiveDragStart = function() {
                this.interactivityState.totalDragAngleDifference = 0, this.interactivityState.previousDragAngle = this.getAngleFromDragEvent();
            }, DonutChart.prototype.interactiveDragMove = function() {
                var data = this.data.dataPoints, viewport = this.currentViewport, interactivityState = this.interactivityState;
                if (interactivityState.interactiveChosenSliceFinishedSetting === !0) {
                    var currentDragAngle = this.getAngleFromDragEvent();
                    if (!currentDragAngle) return;
                    var angleDragDiff = interactivityState.previousDragAngle - currentDragAngle;
                    interactivityState.totalDragAngleDifference += angleDragDiff, interactivityState.previousDragAngle = currentDragAngle, 
                    interactivityState.currentRotate += angleDragDiff, this.svg.select("g").attr("transform", visuals.SVGUtil.translateAndRotate(viewport.width / 2, viewport.height / 2, 0, 0, this.interactivityState.currentRotate));
                    var currentHigherLimit = data[0].data.percentage * interactivityState.valueToAngleFactor, currentAngle = interactivityState.currentRotate <= 0 ? interactivityState.currentRotate * -1 % 360 : 360 - interactivityState.currentRotate % 360;
                    interactivityState.currentIndexDrag = 0;
                    for (var dataLength = data.length; interactivityState.currentIndexDrag < dataLength && currentAngle > currentHigherLimit; ) interactivityState.currentIndexDrag < dataLength - 1 && (currentHigherLimit += data[interactivityState.currentIndexDrag + 1].data.percentage * interactivityState.valueToAngleFactor), 
                    interactivityState.currentIndexDrag++;
                    interactivityState.currentIndexDrag !== interactivityState.previousIndexDrag && (interactivityState.interactiveLegend.updateLegend(interactivityState.currentIndexDrag), 
                    this.svg.selectAll(".slice").attr("opacity", function(d, index) {
                        return index === interactivityState.currentIndexDrag ? DonutChart.OpaqueOpacity : DonutChart.SemiTransparentOpacity;
                    }), interactivityState.previousIndexDrag = interactivityState.currentIndexDrag);
                }
            }, DonutChart.prototype.interactiveDragEnd = function() {
                0 !== this.interactivityState.totalDragAngleDifference && (this.setInteractiveChosenSlice(this.interactivityState.currentIndexDrag), 
                d3.event.sourceEvent.stopPropagation());
            }, DonutChart.prototype.updateInternalToMove = function(data, duration) {
                void 0 === duration && (duration = 0);
                var svg = this.svg, pie = this.pie, key = this.key, arc = this.arc, radius = this.radius, previousRadius = this.previousRadius, sliceWidthRatio = this.sliceWidthRatio, existingData = this.svg.select(".slices").selectAll("path" + DonutChart.sliceClass.selector).data().map(function(d) {
                    return d.data;
                });
                0 === existingData.length && (existingData = data.dataPointsToDeprecate);
                var is = this.mergeDatasets(existingData, data.dataPointsToDeprecate), slice = svg.select(".slices").selectAll("path" + DonutChart.sliceClass.selector).data(pie(data.dataPointsToDeprecate), key);
                slice.enter().insert("path").classed(DonutChart.sliceClass.class, !0).each(function(d) {
                    this._current = d;
                }), slice = svg.select(".slices").selectAll("path" + DonutChart.sliceClass.selector).data(pie(is), key);
                var innerRadius = radius * sliceWidthRatio;
                if (DonutChart.isSingleColor(data.dataPoints), slice.style("fill", function(d) {
                    return d.data.color;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, !1, data.hasHighlights);
                }).style("stroke", "white").style("stroke-dasharray", function(d) {
                    return DonutChart.drawStrokeForDonutChart(radius, DonutChart.InnerArcRadiusRatio, d, sliceWidthRatio);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).transition().duration(duration).attrTween("d", function(d) {
                    var i = d3.interpolate(this._current, d), k = d3.interpolate(previousRadius * DonutChart.InnerArcRadiusRatio, radius * DonutChart.InnerArcRadiusRatio);
                    return this._current = i(0), function(t) {
                        return arc.innerRadius(innerRadius).outerRadius(k(t))(i(t));
                    };
                }), slice = svg.select(".slices").selectAll("path" + DonutChart.sliceClass.selector).data(pie(data.dataPointsToDeprecate), key), 
                slice.exit().transition().delay(duration).duration(0).remove(), !this.isInteractive) {
                    var labelSettings = data.dataLabelsSettings, labels = [];
                    labelSettings && labelSettings.show && (labels = this.createLabels()), visuals.LabelUtils.drawDefaultLabels(this.labelGraphicsContext, labels, !1, !0), 
                    visuals.LabelUtils.drawLabelLeaderLines(this.labelGraphicsContext, labels);
                }
                var highlightSlices;
                data.hasHighlights ? (highlightSlices = svg.select(".slices").selectAll("path" + DonutChart.sliceHighlightClass.selector).data(pie(data.dataPointsToDeprecate), key), 
                highlightSlices.enter().insert("path").classed(DonutChart.sliceHighlightClass.class, !0).each(function(d) {
                    this._current = d;
                }), DonutChart.isSingleColor(data.dataPoints), highlightSlices.style("fill", function(d) {
                    return d.data.color;
                }).style("fill-opacity", 1).style("stroke", "white").style("stroke-dasharray", function(d) {
                    return DonutChart.drawStrokeForDonutChart(radius, DonutChart.InnerArcRadiusRatio, d, sliceWidthRatio, d.data.highlightRatio);
                }).style("stroke-width", function(d) {
                    return 0 === d.data.highlightRatio ? 0 : d.data.strokeWidth;
                }).transition().duration(duration).attrTween("d", function(d) {
                    var i = d3.interpolate(this._current, d), k = d3.interpolate(previousRadius * DonutChart.InnerArcRadiusRatio, DonutChart.getHighlightRadius(radius, sliceWidthRatio, d.data.highlightRatio));
                    return this._current = i(0), function(t) {
                        return arc.innerRadius(innerRadius).outerRadius(k(t))(i(t));
                    };
                }), highlightSlices.exit().transition().delay(duration).duration(0).remove()) : svg.selectAll("path" + DonutChart.sliceHighlightClass.selector).transition().delay(duration).duration(0).remove(), 
                this.assignInteractions(slice, highlightSlices, data), this.tooltipsEnabled && this.addTooltips(slice, highlightSlices), 
                visuals.SVGUtil.flushAllD3TransitionsIfNeeded(this.options), this.isInteractive && (this.addInteractiveLegendArrow(), 
                this.interactivityState.interactiveLegend.drawLegend(this.data.dataPointsToDeprecate), 
                this.setInteractiveChosenSlice(this.interactivityState.lastChosenInteractiveSliceIndex ? this.interactivityState.lastChosenInteractiveSliceIndex : 0));
            }, DonutChart.prototype.addTooltips = function(shapes, highlightShapes) {
                this.tooltipService.addTooltip(shapes, function(args) {
                    return args.data && args.data.data.tooltipInfo;
                }, function(args) {
                    return args.data && args.data.data.identity;
                }), highlightShapes && this.tooltipService.addTooltip(highlightShapes, function(args) {
                    return args.data && args.data.data.tooltipInfo;
                }, function(args) {
                    return args.data && args.data.data.identity;
                });
            }, DonutChart.drawDefaultShapes = function(graphicsContext, donutData, layout, radius, hasSelection, sliceWidthRatio) {
                var shapes = graphicsContext.select(".slices").selectAll("path" + DonutChart.sliceClass.selector).data(donutData.dataPoints, function(d) {
                    return d.data.identity.getKey();
                });
                return shapes.enter().insert("path").classed(DonutChart.sliceClass.class, !0), DonutChart.isSingleColor(donutData.dataPoints), 
                shapes.style("fill", function(d) {
                    return d.data.color;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, hasSelection, donutData.hasHighlights);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).attr(layout.shapeLayout.attrs).style(layout.shapeLayout.styles), shapes.exit().remove(), 
                shapes;
            }, DonutChart.drawDefaultHighlightShapes = function(graphicsContext, donutData, layout, colors, radius, sliceWidthRatio) {
                var shapes = graphicsContext.select(".slices").selectAll("path" + DonutChart.sliceHighlightClass.selector).data(donutData.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                }), function(d) {
                    return d.data.identity.getKey();
                });
                return shapes.enter().insert("path").classed(DonutChart.sliceHighlightClass.class, !0).each(function(d) {
                    this._current = d;
                }), DonutChart.isSingleColor(donutData.dataPoints), shapes.style("fill", function(d) {
                    return d.data.color;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !0, !1, donutData.hasHighlights);
                }).style("stroke", "white").style("stroke-width", function(d) {
                    return 0 === d.data.highlightRatio ? 0 : d.data.strokeWidth;
                }).attr(layout.highlightShapeLayout.attrs).style(layout.highlightShapeLayout.styles), 
                shapes.exit().remove(), shapes;
            }, DonutChart.isSingleColor = function(dataPoints) {
                if (dataPoints.length > 1) {
                    var lastPoint = dataPoints.length - 1;
                    dataPoints[lastPoint].data.isLastInDonut = dataPoints[lastPoint].data.color === dataPoints[0].data.color;
                }
            }, DonutChart.drawStrokeForDonutChart = function(radius, innerArcRadiusRatio, d, sliceWidthRatio, highlightRatio) {
                void 0 === highlightRatio && (highlightRatio = 1);
                var sectionWithoutStroke, sectionWithStroke, sliceRadius = radius * innerArcRadiusRatio * highlightRatio, sliceArc = (d.endAngle - d.startAngle) * sliceRadius;
                if (sliceWidthRatio) {
                    var innerRadius = radius * sliceWidthRatio, outerRadius = highlightRatio * radius * (DonutChart.InnerArcRadiusRatio - sliceWidthRatio), innerSliceArc = (d.endAngle - d.startAngle) * innerRadius;
                    if (d.data.highlightRatio && (sliceArc = (d.endAngle - d.startAngle) * (outerRadius + innerRadius)), 
                    d.data.isLastInDonut) return "0 " + sliceArc + " " + outerRadius + " " + innerSliceArc + " " + outerRadius;
                    sectionWithoutStroke = sliceArc + outerRadius + innerSliceArc, sectionWithStroke = outerRadius;
                } else d.data.isLastInDonut ? (sectionWithoutStroke = sliceArc, sectionWithStroke = 2 * sliceRadius) : (sectionWithoutStroke = sliceArc + sliceRadius, 
                sectionWithStroke = sliceRadius);
                return "0 " + sectionWithoutStroke + " " + sectionWithStroke;
            }, DonutChart.prototype.onClearSelection = function() {
                this.interactivityService && this.interactivityService.clearSelection();
            }, DonutChart.getLayout = function(radius, sliceWidthRatio, outerArcRadiusRatio, viewport) {
                var innerRadius = radius * sliceWidthRatio, outerRadius = radius * outerArcRadiusRatio, zeroRadius = innerRadius || DonutChart.EffectiveZeroValue, innerArc = d3.svg.arc().innerRadius(innerRadius), shapeSlice = d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius), zeroSlice = d3.svg.arc().innerRadius(innerRadius).outerRadius(zeroRadius);
                return {
                    shapeLayout: {
                        attrs: {
                            d: function(d) {
                                return shapeSlice(d);
                            }
                        },
                        styles: {
                            "stroke-dasharray": function(d) {
                                return DonutChart.drawStrokeForDonutChart(radius, outerArcRadiusRatio, d, sliceWidthRatio);
                            }
                        }
                    },
                    highlightShapeLayout: {
                        attrs: {
                            d: function(d) {
                                var highlightArc = innerArc.outerRadius(DonutChart.getHighlightRadius(radius, sliceWidthRatio, d.data.highlightRatio));
                                return highlightArc(d);
                            }
                        },
                        styles: {
                            "stroke-dasharray": function(d) {
                                return DonutChart.drawStrokeForDonutChart(radius, outerArcRadiusRatio, d, sliceWidthRatio, d.data.highlightRatio);
                            }
                        }
                    },
                    zeroShapeLayout: {
                        attrs: {
                            d: function(d) {
                                return zeroSlice(d);
                            }
                        },
                        styles: {
                            "stroke-dasharray": function(d) {
                                return DonutChart.drawStrokeForDonutChart(radius, outerArcRadiusRatio, d, sliceWidthRatio, zeroRadius);
                            }
                        }
                    }
                };
            }, DonutChart.getHighlightRadius = function(radius, sliceWidthRatio, highlightRatio) {
                var innerRadius = radius * sliceWidthRatio;
                return innerRadius + highlightRatio * radius * (DonutChart.InnerArcRadiusRatio - sliceWidthRatio);
            }, DonutChart.cullDataByViewport = function(dataPoints, maxValue, viewport) {
                for (var prevPointColor, estimatedRadius = Math.min(viewport.width, viewport.height) / 2, cullRatio = this.invisibleArcLengthInPixels / (estimatedRadius * DonutChart.twoPi), cullableValue = cullRatio * maxValue, culledDataPoints = [], _i = 0, dataPoints_1 = dataPoints; _i < dataPoints_1.length; _i++) {
                    var datapoint = dataPoints_1[_i];
                    datapoint.measure >= cullableValue && (datapoint.strokeWidth = prevPointColor === datapoint.color ? 1 : 0, 
                    prevPointColor = datapoint.color, culledDataPoints.push(datapoint));
                }
                return culledDataPoints;
            }, DonutChart.ClassName = "donutChart", DonutChart.InteractiveLegendClassName = "donutLegend", 
            DonutChart.InteractiveLegendArrowClassName = "donutLegendArrow", DonutChart.OuterArcRadiusRatio = .9, 
            DonutChart.InnerArcRadiusRatio = .8, DonutChart.OpaqueOpacity = 1, DonutChart.SemiTransparentOpacity = .6, 
            DonutChart.defaultSliceWidthRatio = .48, DonutChart.invisibleArcLengthInPixels = 3, 
            DonutChart.sliceClass = createClassAndSelector("slice"), DonutChart.sliceHighlightClass = createClassAndSelector("slice-highlight"), 
            DonutChart.twoPi = 2 * Math.PI, DonutChart.InteractiveLegendContainerHeight = 70, 
            DonutChart.EffectiveZeroValue = 1e-9, DonutChart.PolylineOpacity = .5, DonutChart;
        }();
        visuals.DonutChart = DonutChart;
        var DonutChartConversion, DonutChartInteractiveLegend = function() {
            function DonutChartInteractiveLegend(donutChart, legendContainer, colors, visualInitOptions) {
                this.maxLegendItemWidth = 15, this.legendContainerParent = legendContainer, this.colors = colors, 
                this.donutChart = donutChart, this.visualInitOptions = visualInitOptions, this.legendItemsPositions = [];
            }
            return DonutChartInteractiveLegend.prototype.drawLegend = function(data) {
                var _this = this;
                this.data = data, this.currentNumberOfLegendItems = data.length, this.currentIndex = 0, 
                this.leftMostIndex = 0, this.rightMostIndex = data.length - 1, this.legendContainerParent.select(DonutChartInteractiveLegend.LegendContainerSelector).empty() && (this.legendContainer = this.legendContainerParent.append("div").classed(DonutChartInteractiveLegend.LegendContainerClassName, !0));
                var legendItems = this.legendContainer.selectAll(DonutChartInteractiveLegend.LegendItemSelector).data(data), legendContainerWidth = this.legendContainerWidth = this.legendContainer.node().getBoundingClientRect().width, initialXOffset = legendContainerWidth / 2 - .4 * legendContainerWidth / 2 + DonutChartInteractiveLegend.ItemMargin, currX = initialXOffset;
                this.currentXOffset = initialXOffset;
                var createLegendItem = function(itemDiv, datum) {
                    itemDiv.attr("data-legend-index", datum.index).css({
                        position: "absolute",
                        left: currX
                    });
                    var itemCategory = visuals.valueFormatter.format(datum.label), itemValue = visuals.valueFormatter.format(datum.originalMeasure, datum.measureFormat), itemPercentage = visuals.valueFormatter.format(datum.percentage, "0.00 %;-0.00 %;0.00 %"), itemColor = datum.color, itemValueSpan = DonutChartInteractiveLegend.createBasicLegendItemSpan(DonutChartInteractiveLegend.LegendItemValueClassName, itemValue, 11), itemCategorySpan = DonutChartInteractiveLegend.createBasicLegendItemSpan(DonutChartInteractiveLegend.LegendItemCategoryClassName, itemCategory, 11), itemPercentageSpan = DonutChartInteractiveLegend.createBasicLegendItemSpan(DonutChartInteractiveLegend.LegendItemPercentageClassName, itemPercentage, 20), valueSpanWidth = DonutChartInteractiveLegend.spanWidth(itemValueSpan), categorySpanWidth = DonutChartInteractiveLegend.spanWidth(itemCategorySpan), precentageSpanWidth = DonutChartInteractiveLegend.spanWidth(itemPercentageSpan), currentLegendBoxWidth = DonutChartInteractiveLegend.legendBoxSize(valueSpanWidth, categorySpanWidth, precentageSpanWidth);
                    itemDiv.css("width", currentLegendBoxWidth), _this.maxLegendItemWidth = Math.max(_this.maxLegendItemWidth, currentLegendBoxWidth);
                    var getLeftValue = function(spanWidth) {
                        return currentLegendBoxWidth - spanWidth > 0 ? (currentLegendBoxWidth - spanWidth) / 2 : 0;
                    }, marginLeftValue = getLeftValue(valueSpanWidth), marginLeftCategory = getLeftValue(categorySpanWidth), marginLeftPrecentage = getLeftValue(precentageSpanWidth);
                    DonutChartInteractiveLegend.createLegendItemSpan(itemCategorySpan, marginLeftCategory), 
                    DonutChartInteractiveLegend.createLegendItemSpan(itemValueSpan, marginLeftValue), 
                    DonutChartInteractiveLegend.createLegendItemSpan(itemPercentageSpan, marginLeftPrecentage).css("color", itemColor), 
                    itemDiv.append(itemCategorySpan), itemDiv.append(itemPercentageSpan), itemDiv.append(itemValueSpan), 
                    _this.legendItemsPositions.push({
                        startX: currX,
                        boxWidth: currentLegendBoxWidth
                    }), currX += currentLegendBoxWidth + DonutChartInteractiveLegend.ItemMargin;
                };
                legendItems.enter().insert("div").classed(DonutChartInteractiveLegend.LegendItemClassName, !0).each(function(d) {
                    createLegendItem($(this), d);
                }), legendItems.exit().remove(), this.assignInteractions();
            }, DonutChartInteractiveLegend.prototype.updateLegend = function(sliceIndex) {
                var _this = this, legendContainerWidth = this.legendContainerWidth;
                this.currentIndex = sliceIndex, this.updateLabelBlocks(sliceIndex);
                var nextXOffset = (this.legendItemsPositions[sliceIndex].startX + this.legendItemsPositions[sliceIndex].boxWidth / 2 - legendContainerWidth / 2) * -1;
                this.legendContainer.transition().styleTween("-webkit-transform", function(d, i, a) {
                    return d3.interpolate(visuals.SVGUtil.translateWithPixels(_this.currentXOffset, 0), visuals.SVGUtil.translateWithPixels(nextXOffset, 0));
                }).styleTween("transform", function(d, i, a) {
                    return d3.interpolate(visuals.SVGUtil.translateWithPixels(_this.currentXOffset, 0), visuals.SVGUtil.translateWithPixels(nextXOffset, 0));
                }).duration(InteractiveOptions.animationDurationMs).ease(InteractiveOptions.ease).each("end", function() {
                    _this.currentXOffset = nextXOffset;
                }), visuals.SVGUtil.flushAllD3TransitionsIfNeeded(this.visualInitOptions);
            }, DonutChartInteractiveLegend.prototype.assignInteractions = function() {
                var _this = this, currentDX = 0, dragStart = function() {
                    currentDX = 0;
                }, dragMove = function() {
                    if (currentDX += d3.event.dx, !(Math.abs(currentDX) < _this.maxLegendItemWidth)) {
                        var dragDirectionLeft = currentDX < 0;
                        _this.dragLegend(dragDirectionLeft), currentDX = 0;
                    }
                }, drag = d3.behavior.drag().origin(Object).on("drag", dragMove).on("dragstart", dragStart);
                this.legendContainer.style({
                    "touch-action": "none",
                    cursor: "pointer"
                }).call(drag);
            }, DonutChartInteractiveLegend.prototype.dragLegend = function(dragDirectionLeft) {
                this.currentNumberOfLegendItems > DonutChartInteractiveLegend.MinimumItemsInLegendForCycled - 1 ? this.currentIndex = this.getCyclingCurrentIndex(dragDirectionLeft) : this.shouldChangeIndexInNonCycling(dragDirectionLeft) && (dragDirectionLeft ? this.currentIndex++ : this.currentIndex--), 
                this.donutChart.setInteractiveChosenSlice(this.currentIndex);
            }, DonutChartInteractiveLegend.prototype.shouldChangeIndexInNonCycling = function(dragDirectionLeft) {
                return !(0 === this.currentIndex && !dragDirectionLeft || this.currentIndex === this.currentNumberOfLegendItems - 1 && dragDirectionLeft);
            }, DonutChartInteractiveLegend.prototype.getCyclingCurrentIndex = function(dragDirectionLeft) {
                var dataLen = this.data.length, delta = dragDirectionLeft ? 1 : -1, newIndex = (this.currentIndex + delta) % (dataLen || 1);
                return newIndex < 0 ? newIndex + dataLen : newIndex;
            }, DonutChartInteractiveLegend.prototype.updateLegendItemsBlocks = function(rightSidedShift, numberOfLegendItemsBlocksToShift) {
                var legendContainer$ = $(this.legendContainer[0]);
                if (rightSidedShift) {
                    var smallestItem = legendContainer$.find("[data-legend-index=" + this.leftMostIndex + "]");
                    smallestItem.remove().insertAfter(legendContainer$.find("[data-legend-index=" + this.rightMostIndex + "]"));
                    var newX = this.legendItemsPositions[this.rightMostIndex].startX + this.legendItemsPositions[this.rightMostIndex].boxWidth + DonutChartInteractiveLegend.ItemMargin;
                    this.legendItemsPositions[this.leftMostIndex].startX = newX, smallestItem.css("left", newX), 
                    this.rightMostIndex = this.leftMostIndex, this.leftMostIndex = (this.leftMostIndex + 1) % this.data.length;
                } else {
                    var highestItem = legendContainer$.find("[data-legend-index=" + this.rightMostIndex + "]");
                    highestItem.remove().insertBefore(legendContainer$.find("[data-legend-index=" + this.leftMostIndex + "]"));
                    var newX = this.legendItemsPositions[this.leftMostIndex].startX - this.legendItemsPositions[this.rightMostIndex].boxWidth - DonutChartInteractiveLegend.ItemMargin;
                    this.legendItemsPositions[this.rightMostIndex].startX = newX, highestItem.css("left", newX), 
                    this.leftMostIndex = this.rightMostIndex, this.rightMostIndex = this.rightMostIndex - 1 === -1 ? this.legendItemsPositions.length - 1 : this.rightMostIndex - 1;
                }
                numberOfLegendItemsBlocksToShift - 1 !== 0 && this.updateLegendItemsBlocks(rightSidedShift, numberOfLegendItemsBlocksToShift - 1);
            }, DonutChartInteractiveLegend.prototype.updateLabelBlocks = function(index) {
                this.currentNumberOfLegendItems > DonutChartInteractiveLegend.MinimumItemsInLegendForCycled ? (this.rightMostIndex === index && this.updateLegendItemsBlocks(!0, 2), 
                this.leftMostIndex === index && this.updateLegendItemsBlocks(!1, 2), (this.rightMostIndex === index + 1 || 0 === this.rightMostIndex && index === this.currentNumberOfLegendItems - 1) && this.updateLegendItemsBlocks(!0, 1), 
                (this.leftMostIndex === index - 1 || this.leftMostIndex === this.currentNumberOfLegendItems - 1 && 0 === index) && this.updateLegendItemsBlocks(!1, 1)) : this.currentNumberOfLegendItems === DonutChartInteractiveLegend.MinimumItemsInLegendForCycled && (this.rightMostIndex === index && this.updateLegendItemsBlocks(!0, 1), 
                this.leftMostIndex === index && this.updateLegendItemsBlocks(!1, 1));
            }, DonutChartInteractiveLegend.createBasicLegendItemSpan = function(spanClass, text, fontSize) {
                return $("<span/>").addClass(spanClass).css({
                    "white-space": "nowrap",
                    "font-size": fontSize + "px"
                }).text(text);
            }, DonutChartInteractiveLegend.createLegendItemSpan = function(existingSpan, marginLeft) {
                return existingSpan.css({
                    overflow: "hidden",
                    "text-overflow": "ellipsis",
                    display: "inline-block",
                    width: "100%",
                    "margin-left": marginLeft
                }), existingSpan;
            }, DonutChartInteractiveLegend.legendBoxSize = function(valueSpanWidth, categorySpanWidth, precentageSpanWidth) {
                var boxSize = valueSpanWidth > categorySpanWidth ? valueSpanWidth : categorySpanWidth;
                return boxSize = boxSize > precentageSpanWidth ? boxSize : precentageSpanWidth, 
                boxSize = boxSize > DonutChartInteractiveLegend.MaxLegendItemBoxSize ? DonutChartInteractiveLegend.MaxLegendItemBoxSize : boxSize + 2;
            }, DonutChartInteractiveLegend.spanWidth = function(span) {
                return this.FakeElementSpan || (this.FakeElementSpan = $("<span>").hide().appendTo(document.body)), 
                this.FakeElementSpan.empty(), this.FakeElementSpan.append(span), this.FakeElementSpan.width();
            }, DonutChartInteractiveLegend.LegendContainerClassName = "legend-container", DonutChartInteractiveLegend.LegendContainerSelector = ".legend-container", 
            DonutChartInteractiveLegend.LegendItemClassName = "legend-item", DonutChartInteractiveLegend.LegendItemSelector = ".legend-item", 
            DonutChartInteractiveLegend.LegendItemCategoryClassName = "category", DonutChartInteractiveLegend.LegendItemPercentageClassName = "percentage", 
            DonutChartInteractiveLegend.LegendItemValueClassName = "value", DonutChartInteractiveLegend.MaxLegendItemBoxSize = 160, 
            DonutChartInteractiveLegend.ItemMargin = 30, DonutChartInteractiveLegend.MinimumItemsInLegendForCycled = 3, 
            DonutChartInteractiveLegend;
        }();
        !function(DonutChartConversion) {
            var DonutChartConverter = function() {
                function DonutChartConverter(dataView, style, tooltipsEnabled) {
                    void 0 === tooltipsEnabled && (tooltipsEnabled = !0);
                    var reader = this.reader = powerbi.data.createDataViewCategoricalReaderAdvanced(dataView, {
                        staticSeriesRole: "Y",
                        colorOptions: {
                            valueRole: "Y",
                            visualStyle: style
                        }
                    }), dataReader = reader.data;
                    this.dataView = dataView;
                    var dataViewCategorical = dataView.categorical;
                    if (this.dataViewMetadata = dataView.metadata, this.tooltipsEnabled = tooltipsEnabled, 
                    this.maxValue = 0, this.hasNegativeValues = !1, this.allValuesAreNegative = !1, 
                    this.style = style, dataViewCategorical.categories && dataViewCategorical.categories.length > 0) {
                        var category = dataViewCategorical.categories[0];
                        this.categoryIdentities = category.identity, this.categoryValues = category.values, 
                        this.allCategoryObjects = category.objects, this.categoryColumnRef = category.identityFields, 
                        this.categoryFormatString = visuals.valueFormatter.getFormatString(category.source, visuals.donutChartProps.general.formatString);
                    }
                    if (this.isDynamicSeries = reader.columns.hasDynamicSeries(), this.highlightsOverflow = !1, 
                    this.total = 0, this.highlightTotal = 0, this.dataPoints = [], this.dataLabelsSettings = null, 
                    dataReader.hasValues("Y")) {
                        var seriesCount = this.seriesCount = dataReader.getSeriesCount();
                        this.hasHighlights = dataReader.hasHighlights();
                        var categoryCount = dataReader.getCategoryCount() || 1;
                        this.allValuesAreNegative = void 0;
                        for (var categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) for (var seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
                            var value = dataReader.getValue("Y", categoryIndex, seriesIndex), highlight = void 0;
                            this.hasHighlights && (highlight = dataReader.getHighlight("Y", categoryIndex, seriesIndex), 
                            null == highlight && (highlight = 0)), void 0 === this.allValuesAreNegative ? this.allValuesAreNegative = (!this.hasHighlights || highlight <= 0) && value <= 0 : this.allValuesAreNegative = this.allValuesAreNegative && (!this.hasHighlights || highlight <= 0) && value <= 0, 
                            this.hasNegativeValues || (this.hasNegativeValues = value < 0 || !!this.hasHighlights && highlight < 0);
                        }
                        this.allValuesAreNegative = !!this.allValuesAreNegative;
                        for (var categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) for (var seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
                            var value = dataReader.getValue("Y", categoryIndex, seriesIndex);
                            if (value = DonutChartConverter.normalizedValue(value, this.allValuesAreNegative), 
                            this.total += value, this.hasHighlights) {
                                var highlight = dataReader.getHighlight("Y", categoryIndex, seriesIndex);
                                highlight = DonutChartConverter.normalizedValue(highlight, this.allValuesAreNegative), 
                                this.highlightTotal += highlight, !this.highlightsOverflow && powerbi.Double.greaterWithPrecision(highlight, value, powerbi.Double.getPrecision(Math.min(highlight, value))) && (this.highlightsOverflow = !0);
                            }
                        }
                    }
                }
                return DonutChartConverter.normalizedValue = function(value, allValuesAreNegative) {
                    return null == value || isNaN(value) ? 0 : value === Number.POSITIVE_INFINITY ? Number.MAX_VALUE : value === Number.NEGATIVE_INFINITY ? -Number.MAX_VALUE : allValuesAreNegative ? Math.abs(value) : value < 0 ? 0 : value;
                }, DonutChartConverter.prototype.convert = function() {
                    var convertedData, reader = this.reader, dataReader = this.reader.data;
                    convertedData = 0 !== this.total ? this.categoryValues ? this.convertCategoricalWithSlicing() : this.isDynamicSeries ? this.convertSeries() : this.convertMeasures() : [], 
                    this.dataLabelsSettings = this.convertDataLabelSettings();
                    var dataViewMetadata = this.dataViewMetadata;
                    if (dataViewMetadata) {
                        var objects = dataViewMetadata.objects;
                        objects && (this.legendObjectProperties = objects.legend);
                    }
                    var category = _.isEmpty(this.dataView.categorical.categories) ? null : this.dataView.categorical.categories[0];
                    this.dataPoints = [];
                    for (var prevPointColor, formatStringProp = visuals.donutChartProps.general.formatString, pctFormatString = visuals.valueFormatter.getLocalizedString("Percentage"), i = 0, dataPointCount = convertedData.length; i < dataPointCount; i++) {
                        var point = convertedData[i], originalMeasure = point.measure, normalizedMeasure = DonutChartConverter.normalizedValue(point.measure, this.allValuesAreNegative), originalHighlight = point.highlightMeasure, normalizedHighlight = DonutChartConverter.normalizedValue(point.highlightMeasure, this.allValuesAreNegative), percentage = this.total > 0 ? normalizedMeasure / this.total : 0, highlightRatio = void 0, highlightPercentage = void 0;
                        normalizedMeasure > this.maxValue && (this.maxValue = normalizedMeasure), normalizedHighlight > this.maxValue && (this.maxValue = normalizedHighlight), 
                        this.hasHighlights && (this.highlightsOverflow ? (originalMeasure = originalHighlight, 
                        normalizedMeasure = normalizedHighlight, percentage = this.highlightTotal > 0 ? normalizedHighlight / this.highlightTotal : 0, 
                        highlightRatio = 1) : highlightRatio = 0 !== normalizedMeasure ? normalizedHighlight / normalizedMeasure : 0, 
                        highlightRatio || (highlightRatio = DonutChart.EffectiveZeroValue), highlightPercentage = percentage * highlightRatio);
                        var categoryValue = point.categoryLabel, categorical = this.dataView.categorical, valueIndex = void 0;
                        valueIndex = null != point.seriesIndex ? point.seriesIndex : i;
                        var valuesMetadata = reader.columns.getValueMetadataColumn("Y", valueIndex), value = this.hasHighlights && this.highlightsOverflow ? originalHighlight : originalMeasure, highlightValue = this.hasHighlights && !this.highlightsOverflow ? originalHighlight : void 0, formatString = visuals.valueFormatter.getFormatString(valuesMetadata, formatStringProp), pct = visuals.valueFormatter.format(percentage, pctFormatString), valueAndPct = void 0;
                        null != value && null != pct && (valueAndPct = visuals.valueFormatter.format(value, formatString) + " (" + pct + ")");
                        var highlightValueAndPct = void 0;
                        if (null != highlightValue && null != highlightPercentage) {
                            var highlightedPct = visuals.valueFormatter.format(highlightPercentage, pctFormatString);
                            highlightValueAndPct = visuals.valueFormatter.format(highlightValue, formatString) + " (" + highlightedPct + ")";
                        }
                        var tooltipInfo = void 0;
                        this.tooltipsEnabled && (tooltipInfo = [], category && tooltipInfo.push({
                            displayName: category.source.displayName,
                            value: categoryValue
                        }), this.isDynamicSeries && (category && category.source === categorical.values.source || tooltipInfo.push({
                            displayName: categorical.values.source.displayName,
                            value: point.label
                        })), null != valueAndPct && tooltipInfo.push({
                            displayName: valuesMetadata.displayName,
                            value: valueAndPct
                        }), null != highlightValueAndPct && tooltipInfo.push({
                            displayName: visuals.ToolTipComponent.localizationOptions.highlightedValueDisplayName,
                            value: highlightValueAndPct
                        }), visuals.TooltipBuilder.addTooltipMeasures(reader, tooltipInfo, this.categoryValues ? point.categoryIndex : 0, this.isDynamicSeries ? point.seriesIndex : void 0, formatStringProp));
                        var strokeWidth = prevPointColor === point.color && percentage && percentage > 0 ? 1 : 0;
                        prevPointColor = percentage && percentage > 0 ? point.color : prevPointColor, this.dataPoints.push({
                            identity: point.identity,
                            measure: normalizedMeasure,
                            originalMeasure: originalMeasure,
                            measureFormat: point.measureFormat,
                            percentage: percentage,
                            index: point.index,
                            label: point.label,
                            highlightRatio: highlightRatio,
                            highlightValue: this.hasHighlights && !this.highlightsOverflow ? normalizedHighlight : void 0,
                            originalHighlightValue: this.hasHighlights && !this.highlightsOverflow ? originalHighlight : void 0,
                            highlightPercentage: this.hasHighlights && !this.highlightsOverflow ? highlightPercentage : void 0,
                            selected: !1,
                            tooltipInfo: tooltipInfo,
                            color: point.color,
                            strokeWidth: strokeWidth,
                            labelFormatString: valuesMetadata.format
                        });
                    }
                    dataReader.hasCategoryWithRole("Category") ? this.legendData = visuals.Legend.buildCategoryLegendData({
                        dataView: this.dataView,
                        categoryRole: "Category",
                        style: this.style,
                        valueRole: "Y",
                        showByDefault: !1
                    }) : this.legendData = visuals.Legend.buildSeriesLegendData({
                        dataView: this.dataView,
                        staticSeriesRole: "Y",
                        style: this.style,
                        showByDefault: !1
                    });
                }, DonutChartConverter.prototype.convertCategoricalWithSlicing = function() {
                    for (var reader = this.reader, dataReader = this.reader.data, dataViewCategorical = this.dataView.categorical, formatStringProp = visuals.donutChartProps.general.formatString, dataPoints = [], categoryIndex = 0, categoryCount = this.categoryValues.length; categoryIndex < categoryCount; categoryIndex++) for (var categoryValue = this.categoryValues[categoryIndex], color = reader.colors.createByCategory(categoryIndex), categoryLabel = visuals.valueFormatter.format(categoryValue, this.categoryFormatString), seriesIndex = 0; seriesIndex < this.seriesCount; seriesIndex++) {
                        var value = dataReader.getValue("Y", categoryIndex, seriesIndex), highlightValue = this.hasHighlights ? dataReader.getHighlight("Y", categoryIndex, seriesIndex) : void 0;
                        if (null != value || null != highlightValue) {
                            var valueColumn = reader.columns.getValueColumn("Y", seriesIndex), label = categoryLabel;
                            (this.isDynamicSeries || dataReader.getSeriesCount() > 1) && (label = visuals.converterHelper.getFormattedLegendLabel(valueColumn.source, dataViewCategorical.values, formatStringProp));
                            var measure = valueColumn.source.queryName, identity = visuals.SelectionIdBuilder.builder().withCategory(dataViewCategorical.categories[0], categoryIndex).withSeries(dataViewCategorical.values, this.isDynamicSeries ? valueColumn : void 0).withMeasure(measure).createSelectionId(), dataPoint = {
                                identity: identity,
                                measureFormat: visuals.valueFormatter.getFormatString(valueColumn.source, formatStringProp, !0),
                                measure: value,
                                highlightMeasure: highlightValue,
                                index: dataPoints.length,
                                label: label,
                                categoryLabel: categoryLabel,
                                color: color,
                                categoryIndex: categoryIndex,
                                seriesIndex: seriesIndex
                            };
                            dataPoints.push(dataPoint);
                        }
                    }
                    return dataPoints;
                }, DonutChartConverter.prototype.convertMeasures = function() {
                    for (var reader = this.reader, dataPoints = [], formatStringProp = visuals.donutChartProps.general.formatString, measureIndex = 0; measureIndex < this.seriesCount; measureIndex++) {
                        var value = reader.data.getValue("Y", 0, measureIndex), highlightValue = this.hasHighlights ? reader.data.getHighlight("Y", 0, measureIndex) : void 0, valueColumn = reader.columns.getValueColumn("Y", measureIndex), measureFormat = visuals.valueFormatter.getFormatString(valueColumn.source, formatStringProp, !0), measureLabel = valueColumn.source.displayName, identity = visuals.SelectionId.createWithMeasure(valueColumn.source.queryName), color = reader.colors.createBySeries(measureIndex), dataPoint = {
                            identity: identity,
                            measureFormat: measureFormat,
                            measure: value,
                            highlightMeasure: highlightValue,
                            index: measureIndex,
                            label: measureLabel,
                            categoryLabel: measureLabel,
                            color: color
                        };
                        dataPoints.push(dataPoint);
                    }
                    return dataPoints;
                }, DonutChartConverter.prototype.convertSeries = function() {
                    for (var reader = this.reader, dataViewCategorical = this.dataView.categorical, dataPoints = [], formatStringProp = visuals.donutChartProps.general.formatString, seriesIndex = 0; seriesIndex < this.seriesCount; seriesIndex++) {
                        var value = reader.data.getValue("Y", 0, seriesIndex), highlightValue = this.hasHighlights ? reader.data.getHighlight("Y", 0, seriesIndex) : void 0, valueColumn = reader.columns.getValueColumn("Y", seriesIndex), seriesFormat = visuals.valueFormatter.getFormatString(valueColumn.source, formatStringProp, !0), label = visuals.converterHelper.getFormattedLegendLabel(valueColumn.source, dataViewCategorical.values, formatStringProp), identity = new visuals.SelectionIdBuilder().withSeries(dataViewCategorical.values, valueColumn).withMeasure(valueColumn.source.queryName).createSelectionId(), color = reader.colors.createBySeries(seriesIndex), dataPoint = {
                            identity: identity,
                            measureFormat: seriesFormat,
                            measure: value,
                            highlightMeasure: highlightValue,
                            index: seriesIndex,
                            label: label,
                            categoryLabel: label,
                            color: color,
                            seriesIndex: seriesIndex
                        };
                        dataPoints.push(dataPoint);
                    }
                    return dataPoints;
                }, DonutChartConverter.prototype.convertDataLabelSettings = function() {
                    var dataViewMetadata = this.dataViewMetadata, dataLabelsSettings = DonutChart.getDefaultDonutLabelSettings();
                    if (dataViewMetadata) {
                        var objects = dataViewMetadata.objects;
                        if (objects) {
                            var labelsObj = objects.labels;
                            labelsObj && visuals.LabelUtils.updateLabelSettingsFromLabelsObject(labelsObj, dataLabelsSettings);
                        }
                    }
                    return dataLabelsSettings;
                }, DonutChartConverter;
            }();
            DonutChartConversion.DonutChartConverter = DonutChartConverter;
        }(DonutChartConversion || (DonutChartConversion = {}));
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var WebDonutChartAnimator = function(_super) {
            function WebDonutChartAnimator(options) {
                return _super.call(this, options) || this;
            }
            return __extends(WebDonutChartAnimator, _super), WebDonutChartAnimator.prototype.animate = function(options) {
                var result = {
                    failed: !0,
                    shapes: null,
                    highlightShapes: null
                }, viewModel = options.viewModel, previousViewModel = this.previousViewModel;
                if (viewModel.highlightsOverflow || previousViewModel && previousViewModel.highlightsOverflow) return this.previousViewModel = viewModel, 
                result;
                var previousHasHighlights = previousViewModel && previousViewModel.hasHighlights, currentHasHighlights = viewModel.hasHighlights;
                return previousViewModel && (currentHasHighlights && !previousHasHighlights ? result = this.animateNormalToHighlighted(options) : currentHasHighlights && previousHasHighlights ? result = this.animateHighlightedToHighlighted(options) : !currentHasHighlights && previousHasHighlights && (result = this.animateHighlightedToNormal(options))), 
                this.previousViewModel = viewModel, result;
            }, WebDonutChartAnimator.prototype.animateNormalToHighlighted = function(options) {
                var shapes = this.animateDefaultShapes(options), highlightShapes = options.graphicsContext.select(".slices").selectAll("path.slice-highlight").data(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                }), function(d) {
                    return d.data.identity.getKey();
                });
                return highlightShapes.enter().insert("path").classed("slice-highlight", !0).each(function(d) {
                    this._current = d;
                }), visuals.DonutChart.isSingleColor(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                })), highlightShapes.style("fill", function(d) {
                    return d.data.color ? d.data.color : options.colors.getNewColorScale().getColor(d.data.identity.getKey()).value;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !0, !1, options.viewModel.hasHighlights);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).attr(options.layout.shapeLayout.attrs).style(options.layout.shapeLayout.styles).transition().duration(this.animationDuration).attr(options.layout.highlightShapeLayout.attrs).style(options.layout.highlightShapeLayout.styles), 
                highlightShapes.exit().remove(), visuals.LabelUtils.drawDefaultLabels(options.labelGraphicsContext, options.labels, !1, !0, !0), 
                visuals.LabelUtils.drawLabelLeaderLines(options.labelGraphicsContext, options.labels), 
                {
                    failed: !1,
                    shapes: shapes,
                    highlightShapes: highlightShapes
                };
            }, WebDonutChartAnimator.prototype.animateHighlightedToHighlighted = function(options) {
                var shapes = this.animateDefaultShapes(options), highlightShapes = this.animateDefaultHighlightShapes(options);
                return visuals.LabelUtils.drawDefaultLabels(options.labelGraphicsContext, options.labels, !1, !0, !0), 
                visuals.LabelUtils.drawLabelLeaderLines(options.labelGraphicsContext, options.labels), 
                {
                    failed: !1,
                    shapes: shapes,
                    highlightShapes: highlightShapes
                };
            }, WebDonutChartAnimator.prototype.animateHighlightedToNormal = function(options) {
                var hasSelection = options.interactivityService && options.interactivityService.hasSelection(), duration = this.animationDuration, shapes = options.graphicsContext.select(".slices").selectAll("path.slice").data(options.viewModel.dataPoints, function(d) {
                    return d.data.identity.getKey();
                });
                shapes.enter().insert("path").classed("slice", !0).each(function(d) {
                    this._current = d;
                }), visuals.DonutChart.isSingleColor(options.viewModel.dataPoints), shapes.style("fill", function(d) {
                    return d.data.color ? d.data.color : options.colors.getNewColorScale().getColor(d.data.identity.getKey()).value;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, d.data.selected, !d.data.selected);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).transition().duration(duration).attr(options.layout.shapeLayout.attrs).style(options.layout.shapeLayout.styles).transition().duration(0).delay(duration).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, hasSelection, !1);
                }), shapes.exit().remove();
                var highlightShapes = options.graphicsContext.select(".slices").selectAll("path.slice-highlight").data(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                }), function(d) {
                    return d.data.identity.getKey();
                });
                return highlightShapes.enter().insert("path").classed("slice-highlight", !0).each(function(d) {
                    this._current = d;
                }), visuals.DonutChart.isSingleColor(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                })), highlightShapes.exit().style("fill", function(d) {
                    return d.data.color ? d.data.color : options.colors.getNewColorScale().getColor(d.data.identity.getKey()).value;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(!1, !0, !1, !0);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).transition().duration(duration).attr(hasSelection ? options.layout.zeroShapeLayout.attrs : options.layout.shapeLayout.attrs).style(hasSelection ? options.layout.zeroShapeLayout.styles : options.layout.shapeLayout.styles).remove(), 
                visuals.LabelUtils.drawDefaultLabels(options.labelGraphicsContext, options.labels, !1, !0, !0), 
                visuals.LabelUtils.drawLabelLeaderLines(options.labelGraphicsContext, options.labels), 
                {
                    failed: !1,
                    shapes: shapes,
                    highlightShapes: highlightShapes
                };
            }, WebDonutChartAnimator.prototype.animateDefaultShapes = function(options) {
                var shapes = options.graphicsContext.select(".slices").selectAll("path.slice").data(options.viewModel.dataPoints, function(d) {
                    return d.data.identity.getKey();
                });
                return shapes.enter().insert("path").classed("slice", !0).each(function(d) {
                    this._current = d;
                }), visuals.DonutChart.isSingleColor(options.viewModel.dataPoints), shapes.style("fill", function(d) {
                    return d.data.color ? d.data.color : options.colors.getNewColorScale().getColor(d.data.identity.getKey()).value;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, !1, options.viewModel.hasHighlights);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).transition().duration(this.animationDuration).attr(options.layout.shapeLayout.attrs).style(options.layout.shapeLayout.styles), 
                shapes.exit().remove(), shapes;
            }, WebDonutChartAnimator.prototype.animateDefaultHighlightShapes = function(options) {
                var highlightShapes = options.graphicsContext.select(".slices").selectAll("path.slice-highlight").data(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                }), function(d) {
                    return d.data.identity.getKey();
                });
                return highlightShapes.enter().insert("path").classed("slice-highlight", !0).each(function(d) {
                    this._current = d;
                }), visuals.DonutChart.isSingleColor(options.viewModel.dataPoints.filter(function(value) {
                    return null != value.data.highlightRatio;
                })), highlightShapes.style("fill", function(d) {
                    return d.data.color ? d.data.color : options.colors.getNewColorScale().getColor(d.data.identity.getKey()).value;
                }).style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !0, !1, options.viewModel.hasHighlights);
                }).style("stroke-width", function(d) {
                    return d.data.strokeWidth;
                }).transition().duration(this.animationDuration).attr(options.layout.highlightShapeLayout.attrs).style(options.layout.highlightShapeLayout.styles), 
                highlightShapes.exit().remove(), highlightShapes;
            }, WebDonutChartAnimator;
        }(visuals.BaseAnimator);
        visuals.WebDonutChartAnimator = WebDonutChartAnimator;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var DonutChartWebBehavior = function() {
            function DonutChartWebBehavior() {}
            return DonutChartWebBehavior.prototype.bindEvents = function(options, selectionHandler) {
                var slices = this.slices = options.slices, highlightSlices = this.highlightSlices = options.highlightSlices, clearCatcher = options.clearCatcher;
                this.hasHighlights = options.hasHighlights;
                var clickHandler = function(d) {
                    var position = visuals.InteractivityUtils.getPositionOfLastInputEvent();
                    selectionHandler.handleSelection(d.data, d3.event.ctrlKey, position);
                }, contextMenuHandler = function(d) {
                    if (!d3.event.ctrlKey) {
                        var position = visuals.InteractivityUtils.getPositionOfLastInputEvent();
                        selectionHandler.handleContextMenu(d.data, position), d3.event.preventDefault();
                    }
                };
                slices.on("click", clickHandler), slices.on("contextmenu", contextMenuHandler), 
                highlightSlices && (highlightSlices.on("click", clickHandler), highlightSlices.on("contextmenu", contextMenuHandler)), 
                clearCatcher.on("click", function() {
                    d3.event.ctrlKey || selectionHandler.handleClearSelection();
                });
            }, DonutChartWebBehavior.prototype.renderSelection = function(hasSelection) {
                var hasHighlights = this.hasHighlights;
                this.slices.style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !1, hasSelection, hasHighlights && !d.data.selected);
                }), this.highlightSlices && this.highlightSlices.style("fill-opacity", function(d) {
                    return visuals.ColumnUtil.getFillOpacity(d.data.selected, !0, !1, hasHighlights);
                });
            }, DonutChartWebBehavior;
        }();
        visuals.DonutChartWebBehavior = DonutChartWebBehavior;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var FontProperties = powerbi.visuals.FontProperties, labelStyle = powerbi.visuals.labelStyle, LabelUtils = powerbi.visuals.LabelUtils, DonutLabelUtils = powerbi.visuals.DonutLabelUtils, EnumExtensions = jsCommon.EnumExtensions, labelStyleFlagEnum = labelStyle.labelStyleFlagEnum, multiOptionsLabelStyle = [ labelStyle.categoryAndDataAndPercent, labelStyle.categoryAndData, labelStyle.categoryAndPercent, labelStyle.dataAndPercent ], svgEllipsis = "…", DonutLabelLayout = function() {
        function DonutLabelLayout(options, donutChartProperties) {
            this.startingOffset = options.startingOffset, this.maximumOffset = options.maximumOffset, 
            null != options.offsetIterationDelta && (this.offsetIterationDelta = options.offsetIterationDelta), 
            this.donutChartProperties = donutChartProperties, this.center = {
                x: donutChartProperties.viewport.width / 2,
                y: donutChartProperties.viewport.height / 2
            }, this.outerRadius = this.donutChartProperties.radius * this.donutChartProperties.outerArcRadiusRatio, 
            this.innerRadius = this.donutChartProperties.radius / 2 * this.donutChartProperties.innerArcRadiusRatio;
            var textProperties = FontProperties.toTextProperties(donutChartProperties.dataLabelsSettings.fontProperties);
            this.additionalParenthesesWidth = powerbi.TextMeasurementService.measureSvgTextWidth(textProperties, "()"), 
            this.additionalSpaceWidth = powerbi.TextMeasurementService.measureSvgTextWidth(textProperties, " "), 
            this.ellipsisWidth = powerbi.TextMeasurementService.measureSvgTextWidth(textProperties, svgEllipsis);
        }
        return DonutLabelLayout.prototype.layout = function(labelDataPoints) {
            for (var donutLabelDataPointsLayoutInfo = [], _i = 0, labelDataPoints_1 = labelDataPoints; _i < labelDataPoints_1.length; _i++) {
                var donutLabel = labelDataPoints_1[_i];
                donutLabelDataPointsLayoutInfo.push({
                    labelDataPoint: donutLabel,
                    hasBeenRendered: !1,
                    labelSize: donutLabel.textSize
                });
            }
            for (var resultingLabels = [], preferredLabelsLayoutInfo = [], viewport = this.donutChartProperties.viewport, labelDataPointsGroup = {
                labelDataPoints: donutLabelDataPointsLayoutInfo,
                maxNumberOfLabels: labelDataPoints.length
            }, grid = new powerbi.LabelArrangeGrid([ labelDataPointsGroup ], viewport), i = donutLabelDataPointsLayoutInfo.length - 1; i >= 0; i--) {
                var labelPoint = donutLabelDataPointsLayoutInfo[i].labelDataPoint;
                if (labelPoint.isPreferred) {
                    var label = donutLabelDataPointsLayoutInfo.splice(i, 1);
                    preferredLabelsLayoutInfo = label.concat(preferredLabelsLayoutInfo);
                }
            }
            if (preferredLabelsLayoutInfo.length > 0 && (resultingLabels = this.positionLabels(preferredLabelsLayoutInfo, grid)), 
            labelDataPoints.length > 0) {
                var labels = this.positionLabels(donutLabelDataPointsLayoutInfo, grid);
                resultingLabels = resultingLabels.concat(labels);
            }
            return _.filter(resultingLabels, function(d) {
                return d.isVisible;
            });
        }, DonutLabelLayout.prototype.positionLabels = function(donutLabelDataPointsLayoutInfo, grid) {
            for (var resultingLabels = [], offsetDelta = this.offsetIterationDelta, currentOffset = this.startingOffset, currentCenteredOffset = 0; currentOffset <= this.maximumOffset; ) {
                for (var _i = 0, donutLabelDataPointsLayoutInfo_1 = donutLabelDataPointsLayoutInfo; _i < donutLabelDataPointsLayoutInfo_1.length; _i++) {
                    var donutLabelDataPointLayoutInfo = donutLabelDataPointsLayoutInfo_1[_i];
                    if (!donutLabelDataPointLayoutInfo.hasBeenRendered) {
                        var label = this.tryPositionForDonut(donutLabelDataPointLayoutInfo, grid, currentOffset);
                        label && resultingLabels.push(label);
                    }
                }
                currentOffset += offsetDelta, currentCenteredOffset += offsetDelta;
            }
            return resultingLabels;
        }, DonutLabelLayout.prototype.tryPositionForDonut = function(donutLabelDataPointLayoutInfo, grid, currentLabelOffset) {
            var labelPoint = donutLabelDataPointLayoutInfo.labelDataPoint, parentShape = labelPoint.parentShape;
            if (!_.isEmpty(parentShape.validPositions) && 0 !== parentShape.validPositions[0]) {
                var defaultPosition = parentShape.validPositions[0], bestCandidate = this.tryAllPositions(donutLabelDataPointLayoutInfo, grid, defaultPosition, currentLabelOffset);
                if (bestCandidate && 0 === bestCandidate.score) return this.buildLabel(bestCandidate, grid);
                if (_.contains(multiOptionsLabelStyle, this.donutChartProperties.dataLabelsSettings.labelStyle)) {
                    var splitLabelDataPointLayoutInfo = this.splitDonutDataPoint(donutLabelDataPointLayoutInfo, this.donutChartProperties.dataLabelsSettings.labelStyle), bestSplitCandidate = this.tryAllPositions(splitLabelDataPointLayoutInfo, grid, defaultPosition, currentLabelOffset);
                    if (bestSplitCandidate && (!bestCandidate || bestSplitCandidate.score < bestCandidate.score)) return this.buildLabel(bestSplitCandidate, grid);
                }
                return bestCandidate ? this.buildLabel(bestCandidate, grid) : void 0;
            }
        }, DonutLabelLayout.prototype.generateCandidate = function(donutLabelDataPointLayoutInfo, candidatePosition, grid, currentLabelOffset) {
            var labelDataPoint = donutLabelDataPointLayoutInfo.labelDataPoint, angle = this.generateCandidateAngleForPosition(labelDataPoint.donutArcDescriptor, candidatePosition), parentShape = this.getPointPositionForAngle(angle), parentPoint = parentShape.point, score = this.score(labelDataPoint, parentPoint), leaderLinePoints = DonutLabelUtils.getLabelLeaderLineForDonutChart(labelDataPoint.donutArcDescriptor, this.donutChartProperties, parentPoint, angle), leaderLinesSize = DonutLabelUtils.getLabelLeaderLinesSizeForDonutChart(leaderLinePoints), newLabelDataPoint = _.clone(labelDataPoint);
            newLabelDataPoint.angle = angle, newLabelDataPoint.parentShape = parentShape, newLabelDataPoint.leaderLinePoints = leaderLinePoints, 
            newLabelDataPoint.linesSize = leaderLinesSize;
            var boundingBoxs = DonutLabelLayout.tryPositionPoint(grid, parentShape.validPositions[0], newLabelDataPoint, currentLabelOffset, this.center, this.donutChartProperties.viewport), newDonutLabelDataPointLayoutInfo = {
                labelDataPoint: newLabelDataPoint,
                hasBeenRendered: donutLabelDataPointLayoutInfo.hasBeenRendered,
                labelSize: donutLabelDataPointLayoutInfo.labelSize
            };
            return {
                angle: angle,
                point: parentShape,
                score: score,
                labelRects: boundingBoxs,
                donutLabelDataPointLayoutInfo: newDonutLabelDataPointLayoutInfo
            };
        }, DonutLabelLayout.prototype.tryAllPositions = function(donutLabelDataPointLayoutInfo, grid, defaultPosition, currentLabelOffset) {
            var labelDataPoint = donutLabelDataPointLayoutInfo.labelDataPoint, boundingBoxs = DonutLabelLayout.tryPositionPoint(grid, defaultPosition, labelDataPoint, currentLabelOffset, this.center, this.donutChartProperties.viewport), originalPoint = labelDataPoint.parentShape, originalCandidate = {
                point: originalPoint,
                angle: labelDataPoint.angle,
                score: this.score(labelDataPoint, originalPoint.point),
                labelRects: boundingBoxs,
                donutLabelDataPointLayoutInfo: donutLabelDataPointLayoutInfo
            };
            if (boundingBoxs && boundingBoxs.textRect && 0 === originalCandidate.score) return originalCandidate;
            var bestCandidate, positions = [];
            boundingBoxs && boundingBoxs.textRect ? (positions = this.getLabelPointPositions(labelDataPoint, !0), 
            bestCandidate = originalCandidate) : positions = this.getLabelPointPositions(labelDataPoint, !1);
            for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
                var position = positions_1[_i], candidate = this.generateCandidate(donutLabelDataPointLayoutInfo, position, grid, currentLabelOffset);
                if (candidate.labelRects && candidate.labelRects.textRect && (null == bestCandidate || candidate.score < bestCandidate.score) && (bestCandidate = candidate, 
                0 === bestCandidate.score)) return bestCandidate;
            }
            return bestCandidate;
        }, DonutLabelLayout.prototype.buildLabel = function(labelLayout, grid) {
            var isVisible, resultingBoundingBox = labelLayout.labelRects.textRect, donutLabelDataPointLayoutInfo = labelLayout.donutLabelDataPointLayoutInfo, labelPoint = donutLabelDataPointLayoutInfo.labelDataPoint;
            null == labelPoint.categoryLabel && null == labelPoint.dataLabel && null == labelPoint.percentLabel || (isVisible = !0), 
            grid.add(resultingBoundingBox), grid.add(labelLayout.labelRects.horizontalLineRect), 
            grid.add(labelLayout.labelRects.diagonalLineRect), donutLabelDataPointLayoutInfo.hasBeenRendered = !0;
            var left = resultingBoundingBox.left - this.center.x;
            left < 0 ? left += resultingBoundingBox.width / 2 : left -= resultingBoundingBox.width / 2;
            var formattedDataLabel, formattedCategoryLabel, formattedPercentLabel, text, textAnchor = 8 === labelPoint.parentShape.validPositions[0] ? "start" : "end", boundingBox = {
                left: left,
                top: resultingBoundingBox.top - this.center.y,
                height: resultingBoundingBox.height,
                width: resultingBoundingBox.width
            }, labelSettingsStyle = LabelUtils.getLabelStyleFlagType(this.donutChartProperties.dataLabelsSettings.labelStyle), spaceAvailableForCategoryLabels = DonutLabelUtils.getSpaceAvailableForDonutLabels(labelPoint.parentShape.point.x, this.donutChartProperties.viewport), spaceAvailableForDataLabels = spaceAvailableForCategoryLabels, getLabelTailoredText = powerbi.visuals.LabelUtils.getLabelTailoredText;
            if (labelSettingsStyle === labelStyle.labelStyleFlagEnum.categoryAndDataAndPercent ? null == labelPoint.secondRowText ? (spaceAvailableForCategoryLabels /= 3, 
            spaceAvailableForDataLabels = spaceAvailableForCategoryLabels) : spaceAvailableForDataLabels /= 2 : labelSettingsStyle === labelStyleFlagEnum.categoryAndData ? null == labelPoint.secondRowText && (spaceAvailableForCategoryLabels /= 2, 
            spaceAvailableForDataLabels = spaceAvailableForCategoryLabels) : labelSettingsStyle !== labelStyleFlagEnum.categoryAndPercent && labelSettingsStyle !== labelStyleFlagEnum.dataAndPercent || null == labelPoint.secondRowText && (spaceAvailableForCategoryLabels /= 2, 
            spaceAvailableForDataLabels = spaceAvailableForCategoryLabels), EnumExtensions.hasFlag(labelSettingsStyle, labelStyle.flagLabelStyleData)) {
                var maxWidth = void 0;
                maxWidth = labelSettingsStyle !== labelStyle.labelStyleFlagEnum.categoryAndDataAndPercent && labelSettingsStyle !== labelStyleFlagEnum.categoryAndData || null != labelPoint.secondRowText ? spaceAvailableForDataLabels : spaceAvailableForDataLabels - this.additionalSpaceWidth, 
                maxWidth < this.ellipsisWidth && (isVisible = !1), formattedDataLabel = getLabelTailoredText({
                    label: labelPoint.dataLabel,
                    maxWidth: maxWidth,
                    fontProperties: labelPoint.fontProperties
                });
            }
            if (EnumExtensions.hasFlag(labelSettingsStyle, labelStyle.flagLabelStyleCategory) && (spaceAvailableForCategoryLabels < this.ellipsisWidth && (isVisible = !1), 
            formattedCategoryLabel = getLabelTailoredText({
                label: labelPoint.categoryLabel,
                maxWidth: spaceAvailableForCategoryLabels,
                fontProperties: labelPoint.fontProperties
            })), EnumExtensions.hasFlag(labelSettingsStyle, labelStyle.flagLabelStylePercent)) {
                var maxWidth = void 0;
                switch (labelSettingsStyle) {
                  case labelStyleFlagEnum.categoryAndDataAndPercent:
                    maxWidth = spaceAvailableForDataLabels - this.additionalParenthesesWidth - this.additionalSpaceWidth;
                    break;

                  case labelStyleFlagEnum.dataAndPercent:
                    maxWidth = null == labelPoint.secondRowText ? spaceAvailableForDataLabels - this.additionalParenthesesWidth - this.additionalSpaceWidth : spaceAvailableForDataLabels - this.additionalParenthesesWidth;
                    break;

                  case labelStyleFlagEnum.categoryAndPercent:
                    maxWidth = spaceAvailableForDataLabels - this.additionalSpaceWidth;
                    break;

                  case labelStyleFlagEnum.percent:
                    maxWidth = spaceAvailableForDataLabels;
                    break;

                  default:
                    maxWidth = spaceAvailableForDataLabels;
                }
                maxWidth < this.ellipsisWidth && (isVisible = !1), formattedPercentLabel = getLabelTailoredText({
                    label: labelPoint.percentLabel,
                    maxWidth: maxWidth,
                    fontProperties: labelPoint.fontProperties
                });
            }
            switch (formattedDataLabel && formattedDataLabel !== svgEllipsis || formattedCategoryLabel && formattedCategoryLabel !== svgEllipsis || formattedPercentLabel && formattedPercentLabel !== svgEllipsis || (isVisible = !1), 
            labelSettingsStyle) {
              case labelStyleFlagEnum.categoryAndDataAndPercent:
                formattedPercentLabel = formattedPercentLabel ? " (" + formattedPercentLabel + ")" : null, 
                null == labelPoint.secondRowText ? (formattedDataLabel = formattedDataLabel ? " " + formattedDataLabel : null, 
                text = formattedCategoryLabel, formattedDataLabel && (text += formattedDataLabel), 
                formattedPercentLabel && (text += formattedPercentLabel)) : (text = formattedPercentLabel ? formattedDataLabel + formattedPercentLabel : formattedDataLabel, 
                labelPoint.secondRowText = formattedCategoryLabel);
                break;

              case labelStyleFlagEnum.categoryAndData:
                null == labelPoint.secondRowText ? (formattedDataLabel = formattedDataLabel ? " " + formattedDataLabel : null, 
                text = formattedDataLabel ? formattedCategoryLabel + formattedDataLabel : formattedCategoryLabel) : (text = formattedDataLabel, 
                labelPoint.secondRowText = formattedCategoryLabel);
                break;

              case labelStyleFlagEnum.categoryAndPercent:
                null == labelPoint.secondRowText ? (formattedPercentLabel = formattedPercentLabel ? " " + formattedPercentLabel : null, 
                text = formattedPercentLabel ? formattedCategoryLabel + formattedPercentLabel : formattedCategoryLabel) : (text = formattedPercentLabel, 
                labelPoint.secondRowText = formattedCategoryLabel);
                break;

              case labelStyleFlagEnum.dataAndPercent:
                null == labelPoint.secondRowText ? (formattedPercentLabel = formattedPercentLabel ? " (" + formattedPercentLabel + ")" : null, 
                text = formattedPercentLabel ? formattedDataLabel + formattedPercentLabel : formattedDataLabel) : (formattedPercentLabel = formattedPercentLabel ? "(" + formattedPercentLabel + ")" : null, 
                text = formattedPercentLabel, labelPoint.secondRowText = formattedDataLabel);
                break;

              case labelStyleFlagEnum.data:
                text = formattedDataLabel;
                break;

              case labelStyleFlagEnum.percent:
                text = formattedPercentLabel;
                break;

              case labelStyleFlagEnum.category:
                text = formattedCategoryLabel;
                break;

              default:
                text = formattedCategoryLabel;
            }
            var limitedSpace;
            return limitedSpace = labelSettingsStyle === labelStyleFlagEnum.categoryAndDataAndPercent && null == labelPoint.secondRowText ? spaceAvailableForCategoryLabels + spaceAvailableForDataLabels + spaceAvailableForDataLabels : labelSettingsStyle === labelStyleFlagEnum.categoryAndData || labelSettingsStyle === labelStyleFlagEnum.categoryAndPercent ? spaceAvailableForCategoryLabels + spaceAvailableForDataLabels : labelSettingsStyle === labelStyleFlagEnum.dataAndPercent ? spaceAvailableForDataLabels + spaceAvailableForDataLabels : spaceAvailableForCategoryLabels, 
            labelPoint.textSize.width = Math.min(labelPoint.textSize.width, limitedSpace), {
                boundingBox: boundingBox,
                text: text,
                tooltip: labelPoint.tooltip,
                isVisible: isVisible,
                identity: labelPoint.identity,
                fontProperties: FontProperties.inherit(labelPoint.fontProperties, {
                    color: labelPoint.outsideFill
                }),
                selected: !1,
                textAnchor: textAnchor,
                leaderLinePoints: labelPoint.leaderLinePoints,
                hasBackground: !1,
                secondRowText: labelPoint.secondRowText
            };
        }, DonutLabelLayout.tryPositionPoint = function(grid, position, labelDataPoint, offset, center, viewport) {
            var parentPoint = labelDataPoint.parentShape, textSize = _.clone(labelDataPoint.textSize);
            textSize.width = Math.min(textSize.width, DonutLabelUtils.getSpaceAvailableForDonutLabels(parentPoint.point.x, viewport));
            var labelRect = powerbi.DataLabelPointPositioner.getLabelRect(textSize, parentPoint, position, offset), diagonalLineParentPoint = {
                point: {
                    x: labelDataPoint.leaderLinePoints[0][0],
                    y: labelDataPoint.leaderLinePoints[0][1] < 0 ? labelDataPoint.leaderLinePoints[1][1] : labelDataPoint.leaderLinePoints[0][1]
                },
                radius: 0,
                validPositions: null
            }, diagonalLineRect = powerbi.DataLabelPointPositioner.getLabelRect(labelDataPoint.linesSize[DonutLabelUtils.DiagonalLineIndex], diagonalLineParentPoint, position, offset), horizontalLineParentPoint = {
                point: {
                    x: labelDataPoint.leaderLinePoints[1][0],
                    y: labelDataPoint.leaderLinePoints[1][1]
                },
                radius: 0,
                validPositions: null
            }, horizontalLineRect = powerbi.DataLabelPointPositioner.getLabelRect(labelDataPoint.linesSize[DonutLabelUtils.HorizontalLineIndex], horizontalLineParentPoint, position, offset);
            if (labelRect && diagonalLineRect && horizontalLineRect) {
                labelRect.left += center.x, labelRect.top += center.y;
                var centerForLinesWidth = center.x - labelRect.width / 2;
                return diagonalLineRect.left += centerForLinesWidth, diagonalLineRect.top += center.y, 
                horizontalLineRect.left += centerForLinesWidth, horizontalLineRect.top += center.y, 
                grid.hasConflict(labelRect) || grid.hasConflict(diagonalLineRect) || grid.hasConflict(horizontalLineRect) ? void 0 : {
                    textRect: labelRect,
                    diagonalLineRect: diagonalLineRect,
                    horizontalLineRect: horizontalLineRect
                };
            }
        }, DonutLabelLayout.prototype.getLabelPointPositions = function(labelPoint, isTruncated) {
            var parentShape = labelPoint.parentShape, position = parentShape.validPositions[0];
            return isTruncated ? parentShape.point.y < 0 ? 8 === position ? [ 64 ] : [ 128 ] : 8 === position ? [ 16 ] : [ 32 ] : 4 === position ? [ 128, 32 ] : [ 16, 64 ];
        }, DonutLabelLayout.prototype.splitDonutDataPoint = function(donutLabelDataPointLayoutInfo, labelSettingStyle) {
            var percentLabelWidth, labelPoint = donutLabelDataPointLayoutInfo.labelDataPoint, categoryLabelWidth = labelPoint.categoryLabelSize ? labelPoint.categoryLabelSize.width : 0, dataLabelWidth = labelPoint.dataLabelSize ? labelPoint.dataLabelSize.width : 0;
            percentLabelWidth = labelPoint.percentLabelSize ? labelSettingStyle === labelStyle.dataAndPercent ? labelPoint.percentLabelSize.width + this.additionalParenthesesWidth : labelSettingStyle === labelStyle.categoryAndDataAndPercent ? labelPoint.percentLabelSize.width + this.additionalParenthesesWidth + this.additionalSpaceWidth : labelPoint.percentLabelSize.width : 0;
            var categoryLabelHeight = labelPoint.categoryLabelSize ? labelPoint.categoryLabelSize.height : 0, dataLabelHeight = labelPoint.dataLabelSize ? labelPoint.dataLabelSize.height : 0, percentLabelHeight = labelPoint.percentLabelSize ? labelPoint.percentLabelSize.height : 0, textSize = {
                width: labelSettingStyle === labelStyle.dataAndPercent ? Math.max(dataLabelWidth, percentLabelWidth) : Math.max(categoryLabelWidth, dataLabelWidth + percentLabelWidth),
                height: 2 * Math.max(categoryLabelHeight, Math.max(dataLabelHeight, percentLabelHeight))
            }, newLabelDataPoint = _.clone(labelPoint);
            newLabelDataPoint.textSize = textSize, newLabelDataPoint.secondRowText = labelSettingStyle === labelStyle.dataAndPercent ? labelPoint.dataLabel : labelPoint.categoryLabel;
            var newLabelPointLayoutInfo = {
                labelDataPoint: newLabelDataPoint,
                hasBeenRendered: donutLabelDataPointLayoutInfo.hasBeenRendered,
                labelSize: donutLabelDataPointLayoutInfo.labelSize
            };
            return newLabelPointLayoutInfo;
        }, DonutLabelLayout.prototype.generateCandidateAngleForPosition = function(d, position) {
            var midAngle = d.startAngle + (d.endAngle - d.startAngle) / 2;
            switch (position) {
              case 64:
              case 32:
                return (d.startAngle + midAngle - Math.PI) / 2;

              case 128:
              case 16:
                return (midAngle + d.endAngle - Math.PI) / 2;
            }
        }, DonutLabelLayout.prototype.getPointPositionForAngle = function(angle) {
            var labelX = DonutLabelUtils.getXPositionForDonutLabel(Math.cos(angle) * this.outerRadius), labelY = Math.sin(angle) * this.outerRadius, newPosition = labelX < 0 ? 4 : 8, pointPosition = {
                point: {
                    x: labelX,
                    y: labelY
                },
                validPositions: [ newPosition ],
                radius: 0
            };
            return pointPosition;
        }, DonutLabelLayout.prototype.score = function(labelPoint, point) {
            var textWidth, spaceAvailableForLabels = DonutLabelUtils.getSpaceAvailableForDonutLabels(point.x, this.donutChartProperties.viewport), labelSettingsStyle = this.donutChartProperties.dataLabelsSettings.labelStyle, categoryLabelWidth = labelPoint.categoryLabelSize ? labelPoint.categoryLabelSize.width : 0, dataLabelWidth = labelPoint.dataLabelSize ? labelPoint.dataLabelSize.width : 0, percentLabelWidth = labelPoint.percentLabelSize ? labelPoint.percentLabelSize.width : 0;
            if (labelSettingsStyle === labelStyle.categoryAndDataAndPercent) {
                if (null != labelPoint.secondRowText) {
                    var firstLineScore = Math.max(categoryLabelWidth - spaceAvailableForLabels, 0), secondeLineScore = Math.max(Math.max(dataLabelWidth, percentLabelWidth + this.additionalParenthesesWidth + this.additionalSpaceWidth) - spaceAvailableForLabels / 2, 0);
                    return Math.max(firstLineScore, secondeLineScore);
                }
                textWidth = Math.max(categoryLabelWidth, dataLabelWidth + this.additionalSpaceWidth, percentLabelWidth + this.additionalParenthesesWidth + this.additionalSpaceWidth), 
                spaceAvailableForLabels /= 3;
            } else labelSettingsStyle === labelStyle.categoryAndData && null == labelPoint.secondRowText ? (textWidth = Math.max(categoryLabelWidth, dataLabelWidth + this.additionalSpaceWidth), 
            spaceAvailableForLabels /= 2) : labelSettingsStyle === labelStyle.categoryAndPercent && null == labelPoint.secondRowText ? (textWidth = Math.max(categoryLabelWidth, percentLabelWidth + this.additionalSpaceWidth), 
            spaceAvailableForLabels /= 2) : labelSettingsStyle === labelStyle.dataAndPercent ? (textWidth = null == labelPoint.secondRowText ? Math.max(dataLabelWidth, percentLabelWidth + this.additionalParenthesesWidth + this.additionalSpaceWidth) : Math.max(dataLabelWidth, percentLabelWidth + this.additionalParenthesesWidth), 
            spaceAvailableForLabels /= 2) : textWidth = labelPoint.textSize.width;
            return Math.max(textWidth - spaceAvailableForLabels, 0);
        }, DonutLabelLayout;
    }();
    powerbi.DonutLabelLayout = DonutLabelLayout;
}(powerbi || (powerbi = {}));